O'Reilly logo

Programming in Objective-C, Sixth Edition by Stephen G. Kochan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enumerating a Dictionary

Program 15.18 illustrates how a dictionary can be defined with initial key-value pairs using the dictionaryWithObjectsAndKeys: method. An immutable dictionary is created, and the program also shows how a fast enumeration loop can be used to retrieve each element from a dictionary one key at a time. Unlike array objects, dictionary objects are not ordered, so the first key-object pair placed in a dictionary might not be the first key extracted when the dictionary is enumerated.

Program 15.18

#import <Foundation/Foundation.h>int main (int argc, char * argv[]){   @autoreleasepool {      NSDictionary *glossary =       [NSDictionary dictionaryWithObjectsAndKeys:        @"A class defined so other ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required