NSMutableArray *arrayOfPredicates=[[NSMutableArray alloc]init];
[self.attendeeListSet enumerateObjectsUsingBlock:^(id obj, BOOL *stop){
NSString *userId=[obj userId];
[arrayOfPredicates addObject:[NSPredicate predicateWithFormat:@"userID == %@",userId]];
}];
NSPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:arrayOfPredicates];
[request setPredicate:compoundPredicate];
我正在为一个数组中的多个userIds设置这个复合谓词,我需要使用OR从这些用户id获取用户。复合谓词不工作
以上不工作,但是当我使用
NSPredicate *predicate1=[NSPredicate predicateWithFormat:@"(userID like[cd] %@)
OR (userID like[cd] %@)",@"sheetal2", @"sheetal3"];
[arrayOfPredicates addObject:predicate1];
现在,这是working..Can anyboady告诉硬编码什么我的代码问题..
感谢
这可能听起来很傻,您正在使用用户ID的第一个和其他的你正在起诉EVENTID? – Anupdas
@Anupdas离开的ID ...什么我是个说的是它不工作...我只是复制pasted..i已经Editted – sheetal
当你发布的问题,没有留下任何余地猜测。即使现在你的上面的查询是区分大小写的,第二个是不区分大小写的?并且还会登录'arrayOfPredicates'来查看他们的内容。 – Anupdas