开发者

Matching NSPredicate With String

开发者 https://www.devze.com 2023-03-27 19:13 出处:网络
I have this predicate which works somewhat well. NSPredicate *filter = [NSPredicate predicateWithFormat:@\"code conta开发者_JAVA百科ins[cd] %@\", predicateFilter];

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

精彩评论

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

关注公众号