Reputation: 4320
I am making a substring comparison and i did it like this
if ([mystring rangeOfString:string options:NSCaseInsensitiveSearch].location == NSNotFound) {
return NO;
} else {
return YES;
}
But this doesn't work while comparing with Read and READ
Upvotes: 1
Views: 111
Reputation: 6427
It will work, try this
NSString *str = @"Read";
NString *matchStr = @"READ";
if ([[str lowercaseString] rangeOfString:[matchStr lowercaseString] ].location == NSNotFound) {
NSLog(@"NO!!");
} else {
NSLog(@"YES!!");
}
Upvotes: 1
Reputation: 9220
Sorry, but your code works for me... If I execute this in XCode:
if ([@"Read" rangeOfString:@"READ" options:NSCaseInsensitiveSearch].location == NSNotFound) {
NSLog(@"NO!!");
} else {
NSLog(@"YES!!");
}
I get this output:
YES!!
Upvotes: 2