NSMutableDictionary Mac OS X 10.0

NSDictionary, being an immutable class, does not allow clients to add, remove, or replace member objects after initialization. NSMutableDictionary, on the other hand, allows for the kinds of operations that alter the contents of the collection. Objects can be added to a mutable dictionary by invoking setObject:forKey:, and objects may be removed using removeObjectForKey:. When an object is added to a dictionary it is sent a retain message; when the object is removed, the dictionary will offset the retain with a release message.

NSMutableDictionary is toll-free bridged with the Core Foundation type CFDictionary. As such, NSMutableDictionary objects can be used interchangeably with the CFDictionary pointer type, CFDictionaryRef.


@interface NSMutableDictionary : NSDictionary
 // Initializers
   - (id)initWithCapacity:(unsigned)numItems;
 // Accessor Methods
   - (void)setObject:(id)anObject forKey:(id)aKey;
   - (void)setDictionary:(NSDictionary *)otherDictionary;
 // Class Methods
   + (id)dictionaryWithCapacity:(unsigned)numItems;
 // Instance Methods
   - (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary;
   - (void)removeAllObjects;
   - (void)removeObjectForKey:(id)aKey;
   - (void)removeObjectsForKeys:(NSArray *)keyArray;

    Part II: API Quick Reference
    Chapter 13. Foundation Classes