NSDictionary

Notice that the dictionary is an instance of NSMutableDictionary. Like an array, a dictionary is a collection object that has an immutable version (NSDictionary) and a mutable version (NSMutableDictionary).

Dictionaries and arrays differ in how they store their objects. An array is an ordered list of pointers to objects that is accessed by an index. When you have an array, you can ask it for the object at the nth index:

/​/​ ​P​u​t​ ​s​o​m​e​ ​o​b​j​e​c​t​ ​a​t​ ​t​h​e​ ​b​e​g​i​n​n​i​n​g​ ​o​f​ ​a​n​ ​a​r​r​a​y​ [​s​o​m​e​A​r​r​a​y​ ​i​n​s​e​r​t​O​b​j​e​c​t​:​s​o​m​e​O​b​j​e​c​t​ ​a​t​I​n​d​e​x​:​0​]​;​ /​/​ ​G​e​t​ ​t​h​a​t​ ​s​a​m​e​ ​o​b​j​e​c​t​ ​o​u​t​ s​o​m​e​O​b​j​e​c​t​ ​=​ ​[​s​o​m​e​A​r​r​a​y​ ​o​b​j​e​c​t​A​t​I​n​d​e​x​:​0​]​;​ ...

Get iOS Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.