I have an NSArray
filled with NSDictionaries
. 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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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]) {
}