I know NSDictionaries as something where you need a key in order to get a value. But how can I iterate over all keys and values in a NSDictionary, so that I know what keys there are, and what values there are? I know there is something called a for-in-loop in JavaScript. Is there something similar in Objective-C?
I know NSDictionaries as something where you need a key in order to get
Share
Yes,
NSDictionarysupports fast enumeration. With Objective-C 2.0, you can do this:The alternate method (which you have to use if you’re targeting Mac OS X pre-10.5, but you can still use on 10.5 and iPhone) is to use an
NSEnumerator: