A mutable key-value pair collection. More...
#import <CPDictionary.h>
Class Methods | |
(id) | + alloc |
(id) | + dictionary |
(id) | + dictionaryWithDictionary: |
(id) | + dictionaryWithJSObject: |
(id) | + dictionaryWithJSObject:recursively: |
(id) | + dictionaryWithObject:forKey: |
(id) | + dictionaryWithObjects:forKeys: |
(id) | + dictionaryWithObjectsAndKeys: |
![]() | |
(BOOL) | + accessInstanceVariablesDirectly |
(id) | + allocWithCoder: |
(BOOL) | + automaticallyNotifiesObserversForKey: |
(void) | + cancelPreviousPerformRequestsWithTarget: |
(void) | + cancelPreviousPerformRequestsWithTarget:selector:object: |
(Class) | + class |
(BOOL) | + conformsToProtocol: |
(void) | + exposeBinding: |
(void) | + initialize |
(IMP) | + instanceMethodForSelector: |
(BOOL) | + instancesRespondToSelector: |
(BOOL) | + isBindingExclusive: |
(BOOL) | + isSubclassOfClass: |
(CPSet) | + keyPathsForValuesAffectingValueForKey: |
(void) | + load |
(id) | + new |
(void) | + object:performSelector:withObject:afterDelay:inModes: |
(void) | + setVersion: |
(Class) | + superclass |
(int) | + version |
A mutable key-value pair collection.
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
:forKey: and -removeObjectForKey
: methods. In Cappuccino there is no distinction between immutable and mutable classes. They are all mutable.
Definition at line 2 of file CPDictionary.h.
|
implementation |
Take all the key/value pairs in aDictionary and apply them to this dictionary.
Definition at line 605 of file CPDictionary.j.
|
implementation |
Returns an array of keys for all the entries in the dictionary.
Definition at line 310 of file CPDictionary.j.
|
implementation |
Returns a new array containing the keys corresponding to all occurrences of a given object in the receiver.
anObject | The value to look for in the receiver. |
Each object in the receiver is sent an isEqual: message to determine if it's equal to anObject. If the check for isEqual fails a check is made to see if the two objects are the same object. This provides compatibility for JSObjects.
Definition at line 338 of file CPDictionary.j.
|
implementation |
Allocates a new instance of the receiving class
Reimplemented from CPObject.
Definition at line 50 of file CPDictionary.j.
|
implementation |
Returns an array of values for all the entries in the dictionary.
Definition at line 318 of file CPDictionary.j.
|
implementation |
Definition at line 647 of file CPDictionary.j.
|
implementation |
return a copy of the receiver (does not deep copy the objects contained in the dictionary).
Reimplemented from CPObject.
Definition at line 294 of file CPDictionary.j.
|
implementation |
Returns the number of entries in the dictionary
Definition at line 302 of file CPDictionary.j.
|
implementation |
Returns a human readable description of the dictionary.
Reimplemented from CPObject.
Definition at line 624 of file CPDictionary.j.
|
implementation |
Returns a new empty CPDictionary.
Definition at line 60 of file CPDictionary.j.
|
implementation |
Returns a new dictionary, initialized with the contents of aDictionary
.
aDictionary | the dictionary to copy key-value pairs from |
Definition at line 70 of file CPDictionary.j.
|
implementation |
Creates a dictionary with multiple key-value pairs.
JavaScript | object |
Definition at line 103 of file CPDictionary.j.
|
implementation |
Creates a dictionary with multiple key-value pairs, recursively.
JavaScript | object |
Definition at line 113 of file CPDictionary.j.
|
implementation |
Creates a new dictionary with single key-value pair.
anObject | the object for the paring |
aKey | the key for the pairing |
Definition at line 81 of file CPDictionary.j.
|
implementation |
Creates a dictionary with multiple key-value pairs.
objects | the objects to place in the dictionary |
keys | the keys for each of the objects |
CPInvalidArgumentException | if the number of objects and keys is different |
Definition at line 93 of file CPDictionary.j.
|
implementation |
Creates and returns a dictionary constructed by a given pairs of keys and values.
firstObject | first object value |
... | key for the first object and ongoing value-key pairs for more objects. |
CPInvalidArgumentException | if the number of objects and keys is different |
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.
Definition at line 185 of file CPDictionary.j.
|
implementation |
Archives the dictionary to a provided coder.
aCoder | the coder to which the dictionary data will be archived. |
Provided by category CPDictionary(CPCoding).
Definition at line 698 of file CPDictionary.j.
|
implementation |
Definition at line 653 of file CPDictionary.j.
|
implementation |
Definition at line 672 of file CPDictionary.j.
|
implementation |
Provided by category CPDictionary(CPCoding).
Definition at line 689 of file CPDictionary.j.
|
implementation |
Initializes the dictionary with the contents of another dictionary.
aDictionary | the dictionary to copy key-value pairs from |
Definition at line 198 of file CPDictionary.j.
|
implementation |
Initializes the dictionary from the arrays of keys and objects.
objects | the objects to put in the dictionary |
keyArray | the keys for the objects to put in the dictionary |
CPInvalidArgumentException | if the number of objects and keys is different |
Definition at line 216 of file CPDictionary.j.
|
implementation |
Creates and returns a dictionary constructed by a given pairs of keys and values.
firstObject | first object value |
... | key for the first object and ongoing value-key pairs for more objects. |
CPInvalidArgumentException | if the number of objects and keys is different |
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 259 of file CPDictionary.j.
|
implementation |
Provided by category CPDictionary(KeyValueObserving).
Definition at line 222 of file CPKeyValueObserving.j.
|
implementation |
Determines if anObject
is functionally equivalent to the receiver.
YES
if anObject
is functionally equivalent to the receiver. Reimplemented from CPObject.
Definition at line 478 of file CPDictionary.j.
|
implementation |
Compare the receiver to this dictionary, and return whether or not they are equal.
Definition at line 447 of file CPDictionary.j.
|
implementation |
Returns an enumerator that enumerates over all the dictionary's keys.
Definition at line 431 of file CPDictionary.j.
|
implementation |
Definition at line 361 of file CPDictionary.j.
|
implementation |
Definition at line 366 of file CPDictionary.j.
|
implementation |
Definition at line 404 of file CPDictionary.j.
|
implementation |
Definition at line 416 of file CPDictionary.j.
|
implementation |
Returns an enumerator that enumerates over all the dictionary's values.
Definition at line 439 of file CPDictionary.j.
|
implementation |
Returns the object for the entry with key aKey
.
aKey | the key for the object's entry |
Definition at line 517 of file CPDictionary.j.
|
implementation |
Removes all the entries from the dictionary.
Definition at line 548 of file CPDictionary.j.
|
implementation |
Removes the entry for the specified key.
aKey | the key of the entry to be removed |
Definition at line 557 of file CPDictionary.j.
|
implementation |
Removes each entry in allKeys from the receiver.
allKeys | an array of keys that will be removed from the dictionary |
Definition at line 566 of file CPDictionary.j.
|
implementation |
Adds an entry into the dictionary.
anObject | the object for the entry |
aKey | the entry's key |
Definition at line 591 of file CPDictionary.j.
|
implementation |
Reimplemented from CPObject.
Provided by category CPDictionary(CPKeyValueCoding).
Definition at line 280 of file CPKeyValueCoding.j.
|
implementation |
Reimplemented from CPObject.
Provided by category CPDictionary(CPKeyValueCoding).
Definition at line 272 of file CPKeyValueCoding.j.