How can I count the occurrence of a character in a string?
Example
String: 123-456-7890
I want to find the occurrence count of \"-\
int num = [[[myString mutableCopy] autorelease] replaceOccurrencesOfString:@"-" withString:@"X" options:NSLiteralSearch range:NSMakeRange(0, [myString length])];
The replaceOccurrencesOfString:withString:options:range:
method returns the number of replacements that were made, so we can use that to work out how many -
s are in your string.