Reputation: 1464
I am using this Code snippet to search for an String inside another String. It works fine for the first if, but then after the second if it only returns YES (true) if I search for both Words (Word from first if, the Word I want to search now)
works if hypothesis contains : "OPEN TWITTER"
not if it is "PLEASE OPEN TWITTER"
p.e.
if ([hypothesis rangeOfString:@"OPEN"].location == !NSNotFound) {
NSLog(@"hypothesis contains OPEN");
if ([hypothesis rangeOfString:@"OPEN TWITTER"].location == !NSNotFound) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"twitter://"]];
}
if ([hypothesis rangeOfString:@"OPEN FACEBOOK"].location == !NSNotFound) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"fb://"]];
}
}
I want it to work also if there are any other Words in the String, I just want to it to hit on the Keywords somewhere in the String and then return YES (to determine that 'hypothesis' contains the words and then do the action)
Upvotes: 0
Views: 99