2

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

2 Answers 2

7
url = [url stringByReplacingOccurrencesOfString:@"id=" withString:@"id=d"];
Sign up to request clarification or add additional context in comments.

Comments

2

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

1 Comment

I have tried stringByReplacingOccurrencesOfString:@"id=" withString:@"id=d"]; but forgot url = ...thx!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.