我使用了编码,我想使用NSPredicate
来过滤结果。我有一个实体,有三个字段:从和到。例如:
从信息
aa bb 11111
aa cc y6767
bb aa 4545
bb dd 3434
所以我想获得from=aa and to=bb
或from =bb and to=aa
,结果是:
从信息
aa bb 11111
bb aa 4545
NSPredicate * predicate = [NSPredicate predicateWithFormat:@“(来自== %@)AND(到>%@)或(从==%@)和(到==%@)“,从,到,到,来自];
或NSPredicate * predicate = [NSPredicate predicateWithFormat:@“(来自 ==%@)AND(到>%@)OR((来自==%@)和(到==%@))“,from,to,to,from];
答案 0 :(得分:0)
尝试
[NSPredicate predicateWithFormat:@"(from == %@ AND to == %@) OR (from == %@ AND to == %@)",
from, to, to, from]