Next Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSMutableDictionary

Inherits from
Implements
Package
com.apple.cocoa.foundation
Companion guide

Class at a Glance

An NSDictionary object stores a mutable set of entries.

Principal Attributes

Creation

NSMutableDictionary

Creates a new dictionary.

Commonly Used Methods

removeObjectForKey

Removes the specified entry from the dictionary.

removeObjectsForKeys

Removes multiple entries from the dictionary.

Overview

The NSMutableDictionary class declares the programmatic interface to objects that manage mutable associations of keys and values. With its two efficient primitive methods—setObjectForKey and removeObjectForKey—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 nonprimitive methods provide convenient ways of adding or removing multiple entries at a time.

Tasks

Constructors

Adding and Removing Entries

Constructors

NSMutableDictionary

public NSMutableDictionary()

Discussion

Creates and returns an empty mutable dictionary.

public NSMutableDictionary(NSDictionary otherDictionary)

Discussion

Creates a mutable dictionary containing the keys and values found in otherDictionary.

Instance Methods

addEntriesFromDictionary

Adds the entries from otherDictionary to the receiver.

public void addEntriesFromDictionary(NSDictionary otherDictionary)

Discussion

Each value object from otherDictionary is added directly to the receiver.

See Also

removeAllObjects

Empties the receiver of its entries.

public void removeAllObjects()

See Also

removeObjectForKey

Removes aKey and its associated value object from the receiver.

public void removeObjectForKey(Object aKey)

Discussion

Does nothing if aKey does not exist.

See Also

removeObjectsForKeys

Removes one or more entries from the receiver.

public void removeObjectsForKeys(NSArray keyArray)

Discussion

The entries are identified by the keys in keyArray. If a key in keyArray does not exist, the entry is ignored.

See Also

setDictionary

Sets the receiver to entries in otherDictionary.

public void setDictionary(NSDictionary otherDictionary)

Discussion

setDictionary does this by removing all entries from the receiver (with removeAllObjects), then adding each entry from otherDictionary into the receiver.

setObjectForKey

Adds an entry to the receiver, consisting of aKey and its corresponding value object anObject.

public void setObjectForKey(Object anObject, Object aKey)

Discussion

The value object is added directly to the dictionary. Throws an InvalidArgumentException if the key or value object is null.

See Also


Next Page > Hide TOC


© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.