Matching NSPredicate With String
I have this predicate which works somewhat well.
NSPredicate *filter = [NSPredicate predicateWithFormat:@"code conta开发者_JAVA百科ins[cd] %@", predicateFilter];
So if predicateFilter
is 112, this finds all code
that have 112
in it. I want it to find all code that BEGIN with 112
instead.
Edit:
I have this predicate, how can I make it so its codes that are between code that begins with predicateFilterStart and code that begins with PredicateFilterEnd?
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@",
[NSArray arrayWithObjects:
[NSExpression expressionForConstantValue: [NSNumber numberWithFloat: [self.predicateFilterStart floatValue]]],
[NSExpression expressionForConstantValue: [NSNumber numberWithFloat: [self.predicateFilterEnd floatValue]]],
nil]];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"code beginswith[cd] %@", predicateFilter];
Predicate Programming Guide
精彩评论