0

我使用了codedate,我想用它NSPredicate来过滤结果。我有一个实体,有三个字段:from 和to。例如:

从 到 信息

AA BB 11111

aa cc y6767

bb aa 4545

bb dd 3434

所以我想得到from=aa and to=bbor 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 ,从];

4

1 回答 1

0

尝试

 [NSPredicate predicateWithFormat:@"(from == %@ AND to == %@) OR (from == %@ AND to == %@)",
        from, to, to, from]
于 2012-10-30T18:01:14.903 回答