NSDictionary
can be enumerated using fast enumeration, just like other collection types:
NSDictionary stockSymbolsDictionary = @{
@"AAPL": @"Apple",
@"GOOGL": @"Alphabet",
@"MSFT": @"Microsoft",
@"AMZN": @"Amazon"
};
for (id key in stockSymbolsDictionary)
{
id value = dictionary[key];
NSLog(@"Key: %@, Value: %@", key, value);
}
Because NSDictionary
is inherently unordered, the order of keys that in the for loop is not guaranteed.