0
您好我有一個這樣的數組:如何使用NSPredicate在字典數組中的字典數組中搜索字符串?
@[
@{@"Name":@"marko"; @"ids"[email protected][@"121",@"156",@"175",@"154"];},
@{@"Name":@"shine";@"ids"[email protected][@"175",@"165",@"154",@"187"];},
@{@"Name":@"David";@"ids"[email protected][@"857",@"297",@"156",@"254"];},
@{@"Name":@"Harry"; @ids"[email protected][@"297",@"154",@"867",@"201"];},
];
如何獲得其使用NSPredicate的ids
數組中的字符串@"156"
的字典。
看一看這個類似的問題:http://stackoverflow.com/questions/958622/using-nspredicate-to-filter-an-nsarray-based-on- nsdictionary-keys –
我這樣工作,但我沒有得到我想要的結果。如果「數組」是mainArray。 NSPredicate * predicate = [NSPredicate predicateWithFormat:@「ids ==%@」,@「156」]; NSArray * filtered = [array filteredArrayUsingPredicate:predicate]; 但它顯示0計數。請給建議。 – Ajay