API  1.0.0
CPDictionary Class Reference

A mutable key-value pair collection. More...

#import <CPDictionary.h>

+ Inheritance diagram for CPDictionary:

Instance Methods

(void) - addEntriesFromDictionary:
 
(CPArray) - allKeys
 
(CPArray) - allKeysForObject:
 
(CPArray) - allValues
 
(BOOL) - containsKey:
 
(CPDictionary- copy
 
(int) - count
 
(CPString- description
 
(void) - encodeWithCoder:
 
(void) - enumerateKeysAndObjectsUsingBlock:
 
(void) - enumerateKeysAndObjectsWithOptions:usingBlock:
 
(id) - initWithCoder:
 
(id) - initWithDictionary:
 
(id) - initWithObjects:forKeys:
 
(id) - initWithObjectsAndKeys:
 
(CPDictionary- inverseChangeDictionary
 
(BOOL) - isEqual:
 
(BOOL) - isEqualToDictionary:
 
(CPEnumerator- keyEnumerator
 
(CPArray) - keysOfEntriesPassingTest:
 
(CPArray) - keysOfEntriesWithOptions:passingTest:
 
(CPArray) - keysSortedByValueUsingComparator:
 
(CPArray) - keysSortedByValueUsingSelector:
 
(CPEnumerator- objectEnumerator
 
(id) - objectForKey:
 
(void) - removeAllObjects
 
(void) - removeObjectForKey:
 
(void) - removeObjectsForKeys:
 
(void) - setObject:forKey:
 
(void) - setValue:forKey:
 
(id) - valueForKey:
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(void) - dealloc
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray) - exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(id) - init
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(void) - performSelector:withObject:afterDelay:
 
(void) - performSelector:withObject:afterDelay:inModes:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(id) + alloc
 
(id) + dictionary
 
(id) + dictionaryWithDictionary:
 
(id) + dictionaryWithJSObject:
 
(id) + dictionaryWithJSObject:recursively:
 
(id) + dictionaryWithObject:forKey:
 
(id) + dictionaryWithObjects:forKeys:
 
(id) + dictionaryWithObjectsAndKeys:
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(void) + cancelPreviousPerformRequestsWithTarget:
 
(void) + cancelPreviousPerformRequestsWithTarget:selector:object:
 
(Class) + class
 
(BOOL) + conformsToProtocol:
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesImplementSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isBindingExclusive:
 
(BOOL) + isSubclassOfClass:
 
(CPSet) + keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + object:performSelector:withObject:afterDelay:inModes:
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Detailed Description

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.

Method Documentation

◆ addEntriesFromDictionary:()

- (void) addEntriesFromDictionary: (CPDictionary aDictionary
implementation

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

Definition at line 603 of file CPDictionary.j.

◆ allKeys()

- (CPArray) allKeys
implementation

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

Definition at line 308 of file CPDictionary.j.

◆ allKeysForObject:()

- (CPArray) allKeysForObject: (id)  anObject
implementation

Returns a new array containing the keys corresponding to all occurrences of a given object in the receiver.

Parameters
anObjectThe value to look for in the receiver.
Returns
A new array containing the keys corresponding to all occurrences of anObject in the receiver. If no object matching anObject is found, returns an empty array.

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 336 of file CPDictionary.j.

◆ alloc()

+ (id) alloc
implementation

Allocates a new instance of the receiving class

Reimplemented from CPObject.

Definition at line 50 of file CPDictionary.j.

◆ allValues()

- (CPArray) allValues
implementation

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

Definition at line 316 of file CPDictionary.j.

◆ containsKey:()

- (BOOL) containsKey: (id)  aKey
implementation

Definition at line 645 of file CPDictionary.j.

◆ copy()

- (CPDictionary) copy
implementation

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

Reimplemented from CPObject.

Definition at line 292 of file CPDictionary.j.

◆ count()

- (int) count
implementation

Returns the number of entries in the dictionary

Definition at line 300 of file CPDictionary.j.

◆ description()

- (CPString) description
implementation

Returns a human readable description of the dictionary.

Reimplemented from CPObject.

Definition at line 622 of file CPDictionary.j.

◆ dictionary()

+ (id) dictionary
implementation

Returns a new empty CPDictionary.

Definition at line 60 of file CPDictionary.j.

◆ dictionaryWithDictionary:()

+ (id) dictionaryWithDictionary: (CPDictionary aDictionary
implementation

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

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

Definition at line 70 of file CPDictionary.j.

◆ dictionaryWithJSObject:()

+ (id) dictionaryWithJSObject: (JSObject)  object
implementation

Creates a dictionary with multiple key-value pairs.

Parameters
JavaScriptobject
Returns
the new CPDictionary

Definition at line 103 of file CPDictionary.j.

◆ dictionaryWithJSObject:recursively:()

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

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

Parameters
JavaScriptobject
Returns
the new CPDictionary

Definition at line 113 of file CPDictionary.j.

◆ dictionaryWithObject:forKey:()

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

Creates a new dictionary with single key-value pair.

Parameters
anObjectthe object for the paring
aKeythe key for the pairing
Returns
the new CPDictionary

Definition at line 81 of file CPDictionary.j.

◆ dictionaryWithObjects:forKeys:()

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

Creates a dictionary with multiple key-value pairs.

Parameters
objectsthe objects to place in the dictionary
keysthe keys for each of the objects
Exceptions
CPInvalidArgumentExceptionif the number of objects and keys is different
Returns
the new CPDictionary

Definition at line 93 of file CPDictionary.j.

◆ dictionaryWithObjectsAndKeys:()

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

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

Parameters
firstObjectfirst object value
...key for the first object and ongoing value-key pairs for more objects.
Exceptions
CPInvalidArgumentExceptionif 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 185 of file CPDictionary.j.

◆ encodeWithCoder:()

- (void) encodeWithCoder: (CPCoder aCoder
implementation

Archives the dictionary to a provided coder.

Parameters
aCoderthe coder to which the dictionary data will be archived.

Provided by category CPDictionary(CPCoding).

Definition at line 696 of file CPDictionary.j.

◆ enumerateKeysAndObjectsUsingBlock:()

- (void) enumerateKeysAndObjectsUsingBlock: (Function /*(id aKey, id anObject, @ref BOOL stop)*/)  aFunction
implementation

Definition at line 651 of file CPDictionary.j.

◆ enumerateKeysAndObjectsWithOptions:usingBlock:()

- (void) enumerateKeysAndObjectsWithOptions: (CPEnumerationOptions)  opts
usingBlock: (Function /*(id aKey, id anObject, @ref BOOL stop)*/)  aFunction 
implementation

Definition at line 670 of file CPDictionary.j.

◆ initWithCoder:()

- (id) initWithCoder: (CPCoder aCoder
implementation

Provided by category CPDictionary(CPCoding).

Definition at line 687 of file CPDictionary.j.

◆ initWithDictionary:()

- (id) initWithDictionary: (CPDictionary aDictionary
implementation

Initializes the dictionary with the contents of another dictionary.

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

Definition at line 198 of file CPDictionary.j.

◆ initWithObjects:forKeys:()

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

Initializes the dictionary from the arrays of keys and objects.

Parameters
objectsthe objects to put in the dictionary
keyArraythe keys for the objects to put in the dictionary
Exceptions
CPInvalidArgumentExceptionif the number of objects and keys is different
Returns
the initialized dictionary

Definition at line 216 of file CPDictionary.j.

◆ initWithObjectsAndKeys:()

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

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

Parameters
firstObjectfirst object value
...key for the first object and ongoing value-key pairs for more objects.
Exceptions
CPInvalidArgumentExceptionif 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 259 of file CPDictionary.j.

◆ inverseChangeDictionary()

- (CPDictionary) inverseChangeDictionary
implementation

Provided by category CPDictionary(KeyValueObserving).

Definition at line 224 of file CPKeyValueObserving.j.

◆ isEqual:()

- (BOOL) isEqual: (id)  anObject
implementation

Determines if anObject is functionally equivalent to the receiver.

Returns
YES if anObject is functionally equivalent to the receiver.

Reimplemented from CPObject.

Definition at line 476 of file CPDictionary.j.

◆ isEqualToDictionary:()

- (BOOL) isEqualToDictionary: (CPDictionary aDictionary
implementation

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

Definition at line 445 of file CPDictionary.j.

◆ keyEnumerator()

- (CPEnumerator) keyEnumerator
implementation

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

Definition at line 429 of file CPDictionary.j.

◆ keysOfEntriesPassingTest:()

- (CPArray) keysOfEntriesPassingTest: (Function /*(id key, id obj, @ref BOOL stop)*/)  predicate
implementation

Definition at line 359 of file CPDictionary.j.

◆ keysOfEntriesWithOptions:passingTest:()

- (CPArray) keysOfEntriesWithOptions: (CPEnumerationOptions)  options
passingTest: (Function /*(id key, id obj, @ref BOOL stop)*/)  predicate 
implementation

Definition at line 364 of file CPDictionary.j.

◆ keysSortedByValueUsingComparator:()

- (CPArray) keysSortedByValueUsingComparator: (Function /*(id obj1, id obj2)*/)  comparator
implementation

Definition at line 402 of file CPDictionary.j.

◆ keysSortedByValueUsingSelector:()

- (CPArray) keysSortedByValueUsingSelector: (SEL)  theSelector
implementation

Definition at line 414 of file CPDictionary.j.

◆ objectEnumerator()

- (CPEnumerator) objectEnumerator
implementation

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

Definition at line 437 of file CPDictionary.j.

◆ objectForKey:()

- (id) objectForKey: (id)  aKey
implementation

Returns the object for the entry with key aKey.

Parameters
aKeythe key for the object's entry
Returns
the object for the entry

Definition at line 515 of file CPDictionary.j.

◆ removeAllObjects()

- (void) removeAllObjects
implementation

Removes all the entries from the dictionary.

Definition at line 546 of file CPDictionary.j.

◆ removeObjectForKey:()

- (void) removeObjectForKey: (id)  aKey
implementation

Removes the entry for the specified key.

Parameters
aKeythe key of the entry to be removed

Definition at line 555 of file CPDictionary.j.

◆ removeObjectsForKeys:()

- (void) removeObjectsForKeys: (CPArray)  keysForRemoval
implementation

Removes each entry in allKeys from the receiver.

Parameters
allKeysan array of keys that will be removed from the dictionary

Definition at line 564 of file CPDictionary.j.

◆ setObject:forKey:()

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

Adds an entry into the dictionary.

Parameters
anObjectthe object for the entry
aKeythe entry's key

Definition at line 589 of file CPDictionary.j.

◆ setValue:forKey:()

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

Reimplemented from CPObject.

Provided by category CPDictionary(CPKeyValueCoding).

Definition at line 280 of file CPKeyValueCoding.j.

◆ valueForKey:()

- (id) valueForKey: (CPString aKey
implementation

Reimplemented from CPObject.

Provided by category CPDictionary(CPKeyValueCoding).

Definition at line 272 of file CPKeyValueCoding.j.


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