开发者

Search nsarray of nsdictionary

I have an NSArray filled with NSDictionaries开发者_Go百科. One of the keys the dicts have in common is "name". I have another array, filled with names. I want to search the first array, if it finds a name it is supposed to add the dictionary to a third mutable array. The third array then contains all dictionary which names are in the name-array.


Use "fast enumeration", commonly also known as for-in loop:

for (NSDictionary* dict in myArray) {

Also, to compare NSString's, use -isEqualToString:.

   if ([[dict objectForKey: myKey] isEqualToString:myString]) {

   }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜