开发者

NSPredicate not filtering correctly

开发者 https://www.devze.com 2023-03-28 00:39 出处:网络
I\'m trying to setup a NSPredicate to开发者_Go百科 filter data. I have a property of an entity called code that is in format like 55.534.

I'm trying to setup a NSPredicate to开发者_Go百科 filter data.

I have a property of an entity called code that is in format like 55.534.

I'm trying to fetch all data in a range, for example 50-60. I have this but it doesn't work.

NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@", [NSArray arrayWithObjects:self.predicateFilterStart, self.predicateFilterEnd, nil]];


First of all, your SQL syntax is wrong. Your predicate format should be

ANY code BETWEEN x AND y

Secondly, %@ formatter should receive NSString, while you're passing NSArray.

Try this:

NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@ AND %@", self.predicateFilterStart, self.predicateFilterEnd];
0

精彩评论

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

关注公众号