开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜