Replacing a single occurrence of string Obj-c
I am trying to replace only one of the occurrences of a NSString with another string. I know that you can use stringByReplacing*开发者_C百科Occurrences*OfString; however, that replaces all occurrences. What I am looking for is more like stringByReplacing*Occurrence*OfString. If anyone could help me that would be great. Thanks, Jnani
Something like this?
NSRange location = [someString rangeOfString:stringToReplace];
NSString* result = [someString stringByReplacingCharactersInRange:location withString:stringToReplaceWith];
精彩评论