Fast Enumeration

suggest change

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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


NSDictionary:
*Fast Enumeration

Table Of Contents