Created
April 17, 2015 01:15
-
-
Save Koze/4bb5d165f050da0e3fd7 to your computer and use it in GitHub Desktop.
NSPredicate with wildcard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testWildcard1 | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF LIKE[c] 'a*e'"]; | |
NSLog(@"%@", predicate); | |
// SELF LIKE[c] "a*e" | |
NSLog(@"%d", [predicate evaluateWithObject:@"apple"]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:@"apple watch"]); | |
// 0 | |
} | |
- (void)testWildcard2 | |
{ | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF LIKE[c] 'a??le'"]; | |
NSLog(@"%@", predicate); | |
// SELF LIKE[c] "a??le" | |
NSLog(@"%d", [predicate evaluateWithObject:@"apple"]); | |
// 1 | |
NSLog(@"%d", [predicate evaluateWithObject:@"appple"]); | |
// 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment