Objective-C Language NSString Searching for a Substring

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

To search if a String contains a substring, do the following:

NSString *myString = @"This is for checking substrings";
NSString *subString = @"checking"; 

BOOL doesContainSubstring = [myString containsString:subString];  // YES

If targeting iOS 7 or OS X 10.9 (or earlier):

BOOL doesContainSubstring = ([myString rangeOfString:subString].location != NSNotFound);  // YES


Got any Objective-C Language Question?