NSDictionary, NSMutableDictionary

Dictionaries are relations of values with keys. Objects are stored in the dictionary with a key. Later, the object can be looked up with the key. The search for matching objects with a key is made efficient by using hash tables.

+(id)dictionaryWithObjectsAndKeys:,... creates a new dictionary from the list of pairs (object, key). The list must end with ,nil,nil.
-(NSArray*)allKeys returns an array (9.3) of all keys in dictionary
-(NSArray*)allValues returns an array (9.3) of all values in dictionary
-(id)objectForKey:(id)key returns the value stored in the dictionary for key or nil if there is none
-(NSEnumerator*)keyEnumerator return enumerator (9.6) over all keys
-(NSEnumerator*)objectEnumerator returns enumerator (9.6) over all values

Class NSMutableDictionary also adds the following methods:

+(id)dictionaryWithCapacity:(int)cap creates a new dictionary with initial allocated space cap
-(id)setObject:(id)obj forKey:(id)key store obj in dictionary for key
-(void)removeObjectForKey:(id)key remove objects matching key
-(void)removeAllObjects get rid of all pairs in dictionary

moltalk@moltalk.org      version of this document: V3.0