NSPredicate not filtering correctly
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];
精彩评论