CPObjectCPDictionary
@implementation CPDictionary : CPObject
A dictionary is the standard way of passing around key-value pairs in
the Cappuccino framework. It is similar to the
Java map interface,
except all keys are CPString
s and values can be any
Cappuccino or JavaScript object.
If you are familiar with dictionaries in Cocoa, you'll notice that
there is no CPMutableDictionary class. The regular CPDictionary
has setObject:
and removeObjectForKey:
methods.
In Cappuccino there is no distinction between immutable and mutable classes.
They are all mutable.
Method Summary | |
---|---|
+(id) | dictionary Returns a new empty CPDictionary . |
+(id) | dictionaryWithDictionary:(CPDictionary)aDictionary Returns a new dictionary, initialized with the contents of aDictionary . |
+(id) | dictionaryWithObject:(id)anObject forKey:(id)aKey Creates a new dictionary with single key-value pair. |
+(id) | dictionaryWithObjects:(CPArray)objects forKeys:(CPArray)keys Creates a dictionary with multiple key-value pairs. |
-(id) | initWithCoder:(CPCoder)aCoder Initializes the dictionary by unarchiving the data from a coder. |
-(id) | initWithDictionary:(CPDictionary)aDictionary Initializes the dictionary with the contents of another dictionary. |
-(id) | initWithObjects:(CPArray)objects forKeys:(CPArray)keyArray Initializes the dictionary from the arrays of keys and objects. |
-(CPArray) | allKeys Returns an array of keys for all the entries in the dictionary. |
-(CPArray) | allValues Returns an array of values for all the entries in the dictionary. |
-(int) | count Returns the number of entries in the dictionary. |
-(CPString) | description Returns a human readable description of the dictionary. |
-(void) | encodeWithCoder:(CPCoder)aCoder Archives the dictionary to a provided coder. |
-(CPEnumerator) | keyEnumerator Returns an enumerator that enumerates over all the dictionary's keys. |
-(CPEnumerator) | objectEnumerator Returns an enumerator that enumerates over all the dictionary's values. |
-(id) | objectForKey:(CPString)aKey Returns the object for the entry with key aKey . |
-(void) | removeAllObjects Removes all the entries from the dictionary. |
-(void) | removeObjectForKey:(id)aKey Removes the entry for the specified key. |
-(void) | setObject:(id)anObject forKey:(id)aKey Adds an entry into the dictionary. |
Method Detail |
---|
+(id)dictionary
CPDictionary
.+(id)dictionaryWithDictionary:(CPDictionary)aDictionary
aDictionary
.aDictionary
- the dictionary to copy key-value pairs fromCPDictionary
+(id)dictionaryWithObject:(id)anObject forKey:(id)aKey
anObject
- the object for the paringaKey
- the key for the pairingCPDictionary
+(id)dictionaryWithObjects:(CPArray)objects forKeys:(CPArray)keys
objects
- the objects to place in the dictionarykeys
- the keys for each of the objectsCPInvalidArgumentException
- if the number of objects and keys is differentCPDictionary
-(id)initWithCoder:(CPCoder)aCoder
aCoder
- the coder from which the data will be unarchived.-(id)initWithDictionary:(CPDictionary)aDictionary
aDictionary
- the dictionary to copy key-value pairs from-(id)initWithObjects:(CPArray)objects forKeys:(CPArray)keyArray
objects
- the objects to put in the dictionarykeyArray
- the keys for the objects to put in the dictionaryCPInvalidArgumentException
- if the number of objects and keys is different-(CPArray)allKeys
-(CPArray)allValues
-(int)count
-(CPString)description
-(void)encodeWithCoder:(CPCoder)aCoder
aCoder
- the coder to which the dictionary data will be archived.-(CPEnumerator)keyEnumerator
-(CPEnumerator)objectEnumerator
-(id)objectForKey:(CPString)aKey
aKey
.aKey
- the key for the object's entry-(void)removeAllObjects
-(void)removeObjectForKey:(id)aKey
aKey
- the key of the entry to be removed-(void)setObject:(id)anObject forKey:(id)aKey
anObject
- the object for the entryaKey
- the entry's keyCreated on Sat Sep 13 14:15:43 PDT 2008