Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

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"];)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top