这是我的回复格式:
[
{
"id": 9001,
"name": "A to B",
"description": "A to B via mooncity",
"sequence":[
1001,
1002,
1003
]
},
{
"id": 9002,
"name": "B to D",
"description": "B to D via suncity",
"sequence":[
1010,
1002,
1009
]
}
]
现在我想获取所有在其序列数组
中具有1002
的字典,并将其放入另一个数组中。
我累了
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"%K contains[c] %@", @"sequence", @"1002"];
但是上面的谓词适用于字典数组。而在这种情况下它不起作用。
任何帮助将不胜感激。
最佳答案
NSPredicate *pred = [NSPredicate predicateWithFormat:@"CAST(sequence, 'NSString') contains[cd] %@", @"1002"];
NSArray *result = [your_array filteredArrayUsingPredicate:pred];
关于ios - 在 Array of Dictionaries of array 中搜索一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39697504/