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 \"-\
The current selected answer will fail if the string starts or ends with the character you are checking for.
Use this instead:
int numberOfOccurances = (int)yourString.length - (int)[yourString stringByReplacingOccurrencesOfString:@"-" withString:@""].length;