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:
// Put some object at the beginning of an array [someArray insertObject:someObject atIndex:0]; // Get that same object out someObject = [someArray objectAtIndex:0];
A dictionary’s objects are not ordered within the collection. So instead of accessing entries with an index, you use a key. The ...
Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.