NSPredicate 未正确过滤
我正在尝试设置 NSPredicate 来过滤数据。
我有一个名为 code 的实体的属性,其格式类似于 55.534
。
我正在尝试获取某个范围内的所有数据,例如 50-60。 我有这个,但不起作用。
NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@", [NSArray arrayWithObjects:self.predicateFilterStart, self.predicateFilterEnd, nil]];
I'm trying to setup a NSPredicate to 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]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,你的SQL语法是错误的。你的谓词格式应该是
其次,%@ 格式化程序应该接收 NSString,而你正在传递 NSArray。
试试这个:
First of all, your SQL syntax is wrong. Your predicate format should be
Secondly, %@ formatter should receive NSString, while you're passing NSArray.
Try this: