i have a string and i want to check for the multiple characters in this string the following code i working fine for one character how to check for the multiple characters.
UPDATE: The previous example was broken, as NSScanner
should not be used like that. Here's a much more straight-forward example:
NSString* string = @"ABCCDEDRFFED";
NSCharacterSet* characters = [NSCharacterSet characterSetWithCharactersInString:@"ABC"];
NSUInteger characterCount;
NSUInteger i;
for (i = 0; i < [yourString length]; i++) {
unichar character = [yourString characterAtIndex:i];
if ([characters characterIsMember:character]) characterCount++;
}
NSLog(@"Total characters = %d", characterCount);