搜尋子字串
要搜尋 String 是否包含子字串,請執行以下操作:
NSString *myString = @"This is for checking substrings";
NSString *subString = @"checking";
BOOL doesContainSubstring = [myString containsString:subString]; // YES
如果定位到 iOS 7 或 OS X 10.9(或更早版本):
BOOL doesContainSubstring = ([myString rangeOfString:subString].location != NSNotFound); // YES