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 classes can inherit from ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access