CPDictionary Class Reference
[Foundation]

List of all members.

Public Member Functions

(id) - initWithDictionary: [implementation]
(id) - initWithObjects:forKeys: [implementation]
(id) - initWithObjectsAndKeys: [implementation]
(CPDictionary- copy [implementation]
(int) - count [implementation]
(CPArray- allKeys [implementation]
(CPArray- allValues [implementation]
(CPEnumerator- keyEnumerator [implementation]
(CPEnumerator- objectEnumerator [implementation]
(BOOL) - isEqualToDictionary: [implementation]
(id) - objectForKey: [implementation]
(void) - removeAllObjects [implementation]
(void) - removeObjectForKey: [implementation]
(void) - removeObjectsForKeys: [implementation]
(void) - setObject:forKey: [implementation]
(void) - addEntriesFromDictionary: [implementation]
(CPString- description [implementation]
(id) - initWithCoder: [implementation]
(void) - encodeWithCoder: [implementation]
(id) - valueForKey: [implementation]
(void) - setValue:forKey: [implementation]

Static Public Member Functions

(id) + dictionary [implementation]
(id) + dictionaryWithDictionary: [implementation]
(id) + dictionaryWithObject:forKey: [implementation]
(id) + dictionaryWithObjects:forKeys: [implementation]
(id) + dictionaryWithJSObject: [implementation]
(id) + dictionaryWithJSObject:recursively: [implementation]
(id) + dictionaryWithObjectsAndKeys: [implementation]


Detailed Description

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 CPStrings 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.

Definition at line 75 of file CPDictionary.j.


Member Function Documentation

- (void) addEntriesFromDictionary: (CPDictionary aDictionary   [implementation]

Take all the key/value pairs in aDictionary and apply them to this dictionary.

Definition at line 528 of file CPDictionary.j.

- (CPArray) allKeys   [implementation]

Returns an array of keys for all the entries in the dictionary.

Definition at line 287 of file CPDictionary.j.

- (CPArray) allValues   [implementation]

Returns an array of values for all the entries in the dictionary.

Definition at line 295 of file CPDictionary.j.

- (CPDictionary) copy   [implementation]

return a copy of the receiver (does not deep copy the objects contained in the dictionary).

Definition at line 271 of file CPDictionary.j.

- (int) count   [implementation]

Returns the number of entries in the dictionary

Definition at line 279 of file CPDictionary.j.

- (CPString) description   [implementation]

Returns a human readable description of the dictionary.

Definition at line 547 of file CPDictionary.j.

+ (id) dictionary   [implementation]

Returns a new empty CPDictionary.

Definition at line 90 of file CPDictionary.j.

+ (id) dictionaryWithDictionary: (CPDictionary aDictionary   [implementation]

Returns a new dictionary, initialized with the contents of aDictionary.

Parameters:
aDictionary the dictionary to copy key-value pairs from
Returns:
the new CPDictionary

Definition at line 100 of file CPDictionary.j.

+ (id) dictionaryWithJSObject: (JSObject)  object   [implementation]

Creates a dictionary with multiple key-value pairs.

Parameters:
JavaScript object
Returns:
the new CPDictionary

Definition at line 133 of file CPDictionary.j.

+ (id) dictionaryWithJSObject: (JSObject)  object
recursively: (BOOL)  recursively 
[implementation]

Creates a dictionary with multiple key-value pairs, recursively.

Parameters:
JavaScript object
Returns:
the new CPDictionary

Definition at line 143 of file CPDictionary.j.

+ (id) dictionaryWithObject: (id)  anObject
forKey: (id)  aKey 
[implementation]

Creates a new dictionary with single key-value pair.

Parameters:
anObject the object for the paring
aKey the key for the pairing
Returns:
the new CPDictionary

Definition at line 111 of file CPDictionary.j.

+ (id) dictionaryWithObjects: (CPArray objects
forKeys: (CPArray keys 
[implementation]

Creates a dictionary with multiple key-value pairs.

Parameters:
objects the objects to place in the dictionary
keys the keys for each of the objects
Exceptions:
CPInvalidArgumentException if the number of objects and keys is different
Returns:
the new CPDictionary

Definition at line 123 of file CPDictionary.j.

+ (id) dictionaryWithObjectsAndKeys: (id)  firstObject
,   ... 
[implementation]

Creates and returns a dictionary constructed by a given pairs of keys and values.

Parameters:
firstObject first object value
... key for the first object and ongoing value-key pairs for more objects.
Exceptions:
CPInvalidArgumentException if the number of objects and keys is different
Returns:
the new CPDictionary
Assuming that there's no object retaining in Cappuccino, you can create dictionaries same way as with alloc and initWithObjectsAndKeys: var dict = [CPDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2"];

Note, that there's no final nil like in Objective-C/Cocoa.

See also:
[CPDictionary - initWithObjectsAndKeys:]

Definition at line 177 of file CPDictionary.j.

- (void) encodeWithCoder: (CPCoder aCoder   [implementation]

Archives the dictionary to a provided coder.

Parameters:
aCoder the coder to which the dictionary data will be archived.

Definition at line 590 of file CPDictionary.j.

- (id) initWithCoder: (CPCoder aCoder   [implementation]

Definition at line 581 of file CPDictionary.j.

- (id) initWithDictionary: (CPDictionary aDictionary   [implementation]

Initializes the dictionary with the contents of another dictionary.

Parameters:
aDictionary the dictionary to copy key-value pairs from
Returns:
the initialized dictionary

Definition at line 190 of file CPDictionary.j.

- (id) initWithObjects: (CPArray objects
forKeys: (CPArray keyArray 
[implementation]

Initializes the dictionary from the arrays of keys and objects.

Parameters:
objects the objects to put in the dictionary
keyArray the keys for the objects to put in the dictionary
Exceptions:
CPInvalidArgumentException if the number of objects and keys is different
Returns:
the initialized dictionary

Definition at line 208 of file CPDictionary.j.

- (id) initWithObjectsAndKeys: (id)  firstObject
,   ... 
[implementation]

Creates and returns a dictionary constructed by a given pairs of keys and values.

Parameters:
firstObject first object value
... key for the first object and ongoing value-key pairs for more objects.
Exceptions:
CPInvalidArgumentException if the number of objects and keys is different
Returns:
the new CPDictionary
You can create dictionaries this way: var dict = [[CPDictionary alloc] initWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2"];

Note, that there's no final nil like in Objective-C/Cocoa.

Definition at line 240 of file CPDictionary.j.

- (BOOL) isEqualToDictionary: (CPDictionary aDictionary   [implementation]

Compare the receiver to this dictionary, and return whether or not they are equal.

Definition at line 325 of file CPDictionary.j.

- (CPEnumerator) keyEnumerator   [implementation]

Returns an enumerator that enumerates over all the dictionary's keys.

Definition at line 309 of file CPDictionary.j.

- (CPEnumerator) objectEnumerator   [implementation]

Returns an enumerator that enumerates over all the dictionary's values.

Definition at line 317 of file CPDictionary.j.

- (id) objectForKey: (CPString aKey   [implementation]

Returns the object for the entry with key aKey.

Parameters:
aKey the key for the object's entry
Returns:
the object for the entry

Definition at line 407 of file CPDictionary.j.

- (void) removeAllObjects   [implementation]

Removes all the entries from the dictionary.

Definition at line 448 of file CPDictionary.j.

- (void) removeObjectForKey: (id)  aKey   [implementation]

Removes the entry for the specified key.

Parameters:
aKey the key of the entry to be removed

Definition at line 459 of file CPDictionary.j.

- (void) removeObjectsForKeys: (CPArray allKeys   [implementation]

Removes each entry in allKeys from the receiver.

Parameters:
allKeys an array of keys that will be removed from the dictionary

Definition at line 468 of file CPDictionary.j.

- (void) setObject: (id)  anObject
forKey: (id)  aKey 
[implementation]

Adds an entry into the dictionary.

Parameters:
anObject the object for the entry
aKey the entry's key

Definition at line 508 of file CPDictionary.j.

- (void) setValue: (id)  aValue
forKey: (CPString aKey 
[implementation]

Definition at line 274 of file CPKeyValueCoding.j.

- (id) valueForKey: (CPString aKey   [implementation]

Definition at line 269 of file CPKeyValueCoding.j.


The documentation for this class was generated from the following files:

Generated on Wed May 20 12:44:00 2009 for Cappuccino by  doxygen 1.5.8