O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

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

CHAPTER 9

image

Dictionaries

NSDictionary

NSDictionary is a class used to organize objects in lists using keys and values. NSDictionary can maintain an index of objects and let you retrieve an object if you have the right key. Usually, the key will be an NSString object while the value will be whatever type of object you are indexing.

To create a dictionary, you include a comma-separate list of key value pairs enclosed in curly brackets and started with the @ symbol.

NSDictionary *d1 = @{@"one": @1, @"two": @2, @"three": @3};

This creates a dictionary of NSNumber objects that you can reference with their string keys. So, the key string @"one" can be ...

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