If the goal of your code is to check if a string contains another string, you can create a category to make this intention clear.
@interface NSString (additions) - (BOOL)containsString:(NSString *)subString; @end @implementation NSString (additions) - (BOOL)containsString:(NSString *)subString { BOOL containsString = NO; NSRange range = [self rangeOfString:subString]; if (range.location != NSNotFound) { containsString = YES; } return containsString; } @end
I have not compiled this code, so you may need to modify it a bit.
Quentin
source share