How do I check if a string contains another string in Objective-C?
NSString *string = @”hello bla bla”; if ([string rangeOfString:@”bla”].location == NSNotFound) { NSLog(@”string does not contain bla”); } else { NSLog(@”string contains bla!”); } The key is noticing that rangeOfString: returns an NSRange struct, and the documentation says that it returns the struct {NSNotFound, 0} if the “haystack” does not contain the “needle”. And if … Read more