I have an NSString or NSMutableString and would like to get the number of occurrences of a particular character.
NSString
NSMutableString
I need to do this for quite a few characters -- uppercase English characters in this case -- so it would be nice for it to be quick.
replaceOccurrencesOfString:withString:options:range: will return the number of characters replaced in a NSMutableString.
replaceOccurrencesOfString:withString:options:range:
[string replaceOccurrencesOfString:@"A" withString:@"B" options:NSLiteralSearch range:NSMakeRange(0, [receiver length])];
2.1m questions
2.1m answers
60 comments
56.9k users