我使用了codedate,我想用它NSPredicate
来过滤结果。我有一个实体,有三个字段:from 和to。例如:
从 到 信息
AA BB 11111
aa cc y6767
bb aa 4545
bb dd 3434
所以我想得到from=aa and to=bb
or from =bb and to=aa
,所以结果是:
从 到 信息
AA BB 11111
bb aa 4545
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(from == %@) AND (to > %@) OR (from == %@) and (to == %@)",from, to,to ,from] ;
或 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(from == %@) AND (to > %@) OR ((from == %@) and (to == %@))",from,to,to ,从];