ios - 如何在 iOS 中对对象的对象值数组使用谓词

标签 ios objective-c arrays nspredicate

我有一个 Exit 对象。 每个导出都有一个类别对象数组。

对象看起来像这样:

类别:(id,名称)

退出:(id,name,number,...,NSArray(Categories),...)

我想使用 NSPredicate 按它们在类别数组中的 类别名称 过滤掉导出,但我不确定如何准确地写下来。 例如,如果我想通过退出名称过滤掉退出,我会这样做

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.exitName = %@", name];
NSArray *results = [exits filteredArrayUsingPredicate:predicate];

但我不确定如何进入类别数组并按类别名称进行搜索。

有什么建议吗?

最佳答案

试试这个

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY SELF.exitName.category_name CONTAINS[c] %@", name];
NSArray *results = [exits filteredArrayUsingPredicate:predicate];

关于ios - 如何在 iOS 中对对象的对象值数组使用谓词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33495920/

相关文章:

sql - 使用列名之一的 Postgres FROM 查询

javascript - 使用函数方法从一系列数组中提取数据

objective-c - 将图像发送到另一个 View Controller UIImageView IOS 5.1

objective-c - 我们可以只提供@2x 图片吗?

objective-c - 使用 NSOperation 出奇地慢

python - 如何在递归编程中编写包含数组中所有元素的乘法表?

ios - 单击后 UITextView 占位符没有消失

ios - 在 Xcode 11 上,如何配置 Intent 在后台运行?

html - 如何在网络上以类似 UICollectionView 的方式显示内容?

iphone - 如何为充满空气的气球制作动画