将 NSPredicate 与字符串匹配
我有这个谓词,效果很好。
NSPredicate *filter = [NSPredicate predicateWithFormat:@"code contains[cd] %@", predicateFilter];
因此,如果 predicateFilter
为 112,则会找到所有 code< /code> 其中包含
112
。我希望它找到所有以 112
开头的代码。
编辑:
我有这个谓词,如何使其代码位于以 predicateFilterStart 开头的代码和以 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]];
I have this predicate which works somewhat well.
NSPredicate *filter = [NSPredicate predicateWithFormat:@"code contains[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]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谓词编程指南
Predicate Programming Guide