我有一个对象实例数组 - MyObject
。每个实例都有一个字符串和一个数组属性 - myArrayProperty
其中包含另一个类的实例 - MyOtherObject
我正在使用 NSPredicate
进行一些基于过滤的操作myArrayProperty
中的值如下:
NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"myArrayProperty.otherObjectProperty MATCHES %@", mySearchString];
在这种情况下,otherObject 属性是 MyOtherObject 的字符串属性。我怀疑问题出在这个结构上:myArrayProperty.otherObjectPropert
我的问题是,如何指示谓词遍历 myArrayProperty 中的所有项?我想避免在这里使用 for 循环。谢谢。
最佳答案
你可以使用...
NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"ANY myArrayProperty.otherObjectProperty MATCHES %@", mySearchString];
我相信。
关于iphone - NSPredicate 检查数组中的所有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13701729/