How do I loop through all objects in a NSMutableDictionary regardless of the keys?
+2
A:
A standard way would look like this
for(id key in myDict) {
id value = [myDict objectForKey:key];
[value doStuff];
}
Henrik P. Hessel
2010-10-12 11:58:52
+2
A:
You can use [dict allValues]
to get an NSArray
of your values. Be aware that it doesn't guarantee any order between calls.
jv42
2010-10-12 12:03:32
I would use this one over the (id key in dictionary), especially on a mutable dictionary, since the latter throws a nasty error if the dictionary is modified while being enumerated.
sigsegv
2010-10-12 13:56:50