我有一个包含字典的数组。在每个字典中再次包含字典数组。我想弄清楚具有特定价值的所有物体,如印度。 我试过NSpredicate。字典从字典数组中找出一个特定的值
{
Destination : [
{
plan : [
{
name : "India"
},
{
name : "India"
}
]
},
{
plan : [
{
name : "Germany"
},
{
name : "Germany"
}
]
}
]
}
的示例阵列本字典我的代码是
NSMutableArray * destinationArray = [[NSMutableArray alloc]init];
[destinationArray addObject:[ResponseObject objectForKey:@"Destination"]];
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@",@"India"];
NSArray * filtered = [destinationArray filteredArrayUsingPredicate:predicate];
你是否对'ResponseObject'阵列或单个对象的多个对象? –
我在我的答案中的数组等于你的[[ResponseObject objectForKey:@“Destination”]',测试我的代码,你会知道你错在哪里。 –