Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights Reserved.


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 methodssetObject: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

Adding and Removing Entries

- (void)setDictionary:(NSDictionary *)otherDictionary

Sets the contents of the receiver to the keys and values in other.