我有以下课程
EntityOne - Property1 : string - Property2 : int - Property3 : Array of EntityTwo EntityTwo - Property1 : string - Property2 : int
我想写一个NSPredicate
,当我在一个包含EntityTwoObj.property1
个对象的数组上执行它时会对EntityOne
进行过滤。
有可能吗?
我试过以下:
NSPredicate *bPredicate = [NSPredicate predicateWithFormat:
@"Property1 CONTAINS[cd] %@
OR Property2 CONTAINS[cd] %@
OR Property3.Property1 CONTAINS[cd] %@",
newString, newString, newString];
但它没有用。
如果我删除了最后一个过滤器,那么它的工作正常。
答案 0 :(得分:0)
感谢@Larm,我可以通过在谓词中添加ANY
运算符来解决它。
NSPredicate *bPredicate = [NSPredicate predicateWithFormat:
@"Property1 CONTAINS[cd] %@
OR Property2 CONTAINS[cd] %@
OR ANY Property3.Property1 CONTAINS[cd] %@",
newString, newString, newString];