Pregunta

I need to add the string @"d" after "id="

Example =

url = @"id=63488320543140151742289377"

needs to be

url = @"id=d63488320543140151742289377"

I have tried this:

NSRange range = [url rangeOfString:@"id="];
[url stringByReplacingCharactersInRange:range withString:@"id=d"];

but not work

¿Fue útil?

Solución

url = [url stringByReplacingOccurrencesOfString:@"id=" withString:@"id=d"];

Otros consejos

stringByReplacingCharactersInRange returns a string. Your code should work if you assign the new string that's returned to some variable (e.g. url = [url stringByReplacingCharactersInRange:range withString:@"id=d"];)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top