Copyright ã1994 by NeXT Computer, Inc.  All Rights Reserved.

NSMutableDictionary 

Inherits From:	NSDictionary : NSObject

Conforms To:	NSCoding, NSCopying, NSMutableCopying (NSDictionary)
NSObject (NSObject)

Declared In:	Foundation/NSDictionary.h 

Class Description

The NSMutableDictionary class declares the programmatic interface to objects that manage mutable associations of keys and values. With its two efficient primitive methodsÐsetObject:forKey: and removeObject:forKey:Ðthis class adds modification operations to the basic operations it inherits from NSDictionary.

The other methods declared here operate by invoking one or both of these primitives. The derived methods provide convenient ways of adding or removing multiple entries at a time.

When an entry is removed from a mutable dictionary, the key and value objects that make up the entry receive a release message, which can cause them to be deallocated. Note that if your program keeps a reference to such objects, the reference will become invalid unless you remember to send the object a retain message before it's removed from the dictionary. For example, the third statement below could result in a run-time error, except for the retain message in the first statement:

id anObject = [[aDictionary objectForKey:theKey] retain];
[aDictionary removeObjectForKey:theKey];
[anObject someMessage];

Allocating and Initializing 

+ (id)allocWithZone:(NSZone *)zone	Creates and returns an uninitialized NSMutableDictionary in zone.

+ (id)dictionaryWithCapacity:(unsigned int)aNumItems	
	Creates and returns an NSMutableDictionary, giving it enough allocated memory to hold numEntries entries.

- (id)initWithCapacity:(unsigned int)aNumItems	Initializes a newly allocated NSMutableDictionary, giving it enough allocated memory to hold numEntries entries.

Adding and Removing Entries 

- (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary	
	Adds the entries from otherDictionary to the receiver.

- (void)removeAllObjects	Empties the receiver of its entries.

- (void)removeObjectForKey:(id)theKey	Removes theKey and its associated value object from the dictionary. Raises NSInvalidArgumentException if aKey is nil.

- (void)removeObjectsForKeys:(NSArray *)keyArray
	Removes from the receiver one or more entries as identified by the keys in keyArray. 

- (void)setObject:(id)anObject	Adds an entry to the receiver, consisting of anObject and its 
forKey:(id)aKey		corresponding key aKey. Raises NSInvalidArgumentException if either anObject or aKey is nil.

- (void)setDictionary:(NSDictionary *)otherDictionary
	Sets the contents of the receiver to the keys and values in other.