How can I check if a string (NSString) contains another smaller string? I was hoping for something like:
NSString *string = @"hello bla bla";
NSLog(@"%d",[string containsSubstring:@"hello"]);
But the closest I could find was:
if ([string rangeOfString:@"hello"] == 0) {
NSLog(@"sub string doesnt exist");
} else {
NSLog(@"exists");
}
I typed that straight into stack so sorry if there are errors, but there would be if I was doing it in Xcode so you don't need to point any out.
Anyway is that the best way to find if a string contains another string.