MPMutableDictionary


A subclass of NSMutableDictionary that is the base of most MacPort API objects

Superclass: NSMutableDictionary
Declared In: MPMutableDictionary.h

Discussion

The dictionary data structure is appropriate for representing various aspects of the MacPorts system such as port objects, receipt objects etc. Clients of this framework can treat subclasses of MPMutableDictionary objects as NSMutableDictionaries which can be useful for some GUI programming tasks like displaying information in a table. In order to properly subclass an NSMutableDictionary, this class also contains an internal NSMutableDictionary object. See http://www.smackie.org/Notes/2007/07/11/subclassing-nsmutabledictionary/ for some more information on subclassing NSMutableDictionary.



Methods

-init
Calls [initWithCapacity:15]
-initWithCapacity:
Initializes this object with a specified number of key, value pairs.
-count
Returns the size of this mutable dictionary
-keyEnumerator
Returns an NSEnumerator object for accessing keys in the mutable dictionary
-objectForKey:
Returns the object associated with a given key
-removeObjectForKey:
Removes a given key and its associated object from the mutable dictionary
-setObject:forKey:
Adds a given key and its associated object to the mutable dictionary.
-setDictionary:
Sets the contents of the mutable dictionary to entries in a given dictionary
-description
Returns an NSString representation of the contents of this mubtable dictioanry, formatted as a property list.

init


Calls [initWithCapacity:15]

- (id)init; 


initWithCapacity:


Initializes this object with a specified number of key, value pairs.

- (id)initWithCapacity:(unsigned)numItems; 
Parameters
numItems
The initial size of this MPMutableDictionary object.


count


Returns the size of this mutable dictionary

- (unsigned)count; 


keyEnumerator


Returns an NSEnumerator object for accessing keys in the mutable dictionary

- (NSEnumerator *)keyEnumerator; 


objectForKey:


Returns the object associated with a given key

- (id)objectForKey:(id)aKey; 
Parameters
aKey
The key for which to return the corresponding object


removeObjectForKey:


Removes a given key and its associated object from the mutable dictionary

- (void)removeObjectForKey:(id)aKey; 
Parameters
aKey
The key to be removed


setObject:forKey:


Adds a given key and its associated object to the mutable dictionary.

- (void)setObject:(id)anObject forKey:(id)aKey; 
Parameters
anObject
The value for the key to be added.
aKey
The key for the value to be added.
Discussion

This class uses an embedded NSMutableDictionary for implementing these primitive methods. Hence restrictions to setObject: forKey: for NSMutableDictionary apply here also; for example, anObject cannot be nil.


setDictionary:


Sets the contents of the mutable dictionary to entries in a given dictionary

- (void)setDictionary:(NSDictionary *)otherDictionary; 
Parameters
otherDictionary
A dictionary containing the new entries


description


Returns an NSString representation of the contents of this mubtable dictioanry, formatted as a property list.

- (NSString *)description; 

Last Updated: Sunday, July 13, 2008