looping through an NSMutableDictionary looping through an NSMutableDictionary ios ios

looping through an NSMutableDictionary


A standard way would look like this

for(id key in myDict) {    id value = [myDict objectForKey:key];    [value doStuff];}


you can use

[myDict enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {    // do something with key and obj}];

if your target OS supports blocks.


You can use [dict allValues] to get an NSArray of your values. Be aware that it doesn't guarantee any order between calls.