How can I find ALL instances of the same character in a string. For instance in the following code it finds the first character in the string, but what I want is to check if something exists multiple times, I don't really want to know how many they are only if there are multiples.
Is there a way to check if a character exists more than once in a NSString?
Thanks a lot
Code:
- (IBAction)findCharacters:(id)sender {
NSString *number = @"Hello World";
NSRange character = [number rangeOfString:@"l"];
if (character.location == NSNotFound) {
NSLog(@"This string DOESN'T contain that character");
}
else{
NSLog(@"This string DOES contain that character");
}
}
Is there a way to check if a character exists more than once in a NSString?
Thanks a lot
Last edited by a moderator: