iphone - NSPredicate 检查数组中的所有项目

标签 iphone objective-c ios nspredicate

我有一个对象实例数组 - 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/

相关文章:

iPhone 和 MySQL

iphone - 访问 NSMutableArray 成员变量时崩溃

ios - 设置 text.view 框架和按钮框架之间的适当间隙

ios - 从 ios 框架启动应用程序或在 safari 中打开链接

iphone - 尝试让 MKPolygon 叠加工作

iphone - 在 XCode 4 项目中编译 ZipArchive

objective-c - 上下文 NSMenu : how to get the NSTableView to which belongs to?

iphone - 获取通讯录中的所有群组名称

ios - 如何在加载响应后加载 View Controller (或调用 segue)(使用 Alamofire)?

ios - 在 Swift 中声明全局变量