ObjFW
|
An abstract class for storing objects in a dictionary. More...
#import <OFDictionary.h>
Public Member Functions | |
(id) | - init |
Initializes an already allocated OFDictionary. | |
(id) | - initWithDictionary: |
Initializes an already allocated OFDictionary with the specified OFDictionary. | |
(id) | - initWithObject:forKey: |
Initializes an already allocated OFDictionary with the specified key and object. | |
(id) | - initWithObjects:forKeys: |
Initializes an already allocated OFDictionary with the specified keys and objects. | |
(id) | - initWithKeysAndObjects: |
Initializes an already allocated OFDictionary with the specified keys and objects. | |
(id) | - initWithKey:arguments: |
Initializes an already allocated OFDictionary with the specified key and va_list. | |
(id) | - objectForKey: |
Returns the object for the given key or nil if the key was not found. | |
(BOOL) | - containsObjectIdenticalTo: |
Checks whether the dictionary contains an object with the specified address. | |
(OFArray *) | - allKeys |
Returns an array of all keys. | |
(OFArray *) | - allObjects |
Returns an array of all objects. | |
(OFEnumerator *) | - keyEnumerator |
Returns an OFEnumerator to enumerate through the dictionary's keys. | |
(void) | - enumerateKeysAndObjectsUsingBlock: |
Executes a block for each key / object pair. | |
(OFDictionary *) | - mappedDictionaryUsingBlock: |
Creates a new dictionary, mapping each object using the specified block. | |
(OFDictionary *) | - filteredDictionaryUsingBlock: |
Creates a new dictionary, only containing the objects for which the block returns YES. | |
Static Public Member Functions | |
(id) | + dictionary |
Creates a new OFDictionary. | |
(id) | + dictionaryWithDictionary: |
Creates a new OFDictionary with the specified dictionary. | |
(id) | + dictionaryWithObject:forKey: |
Creates a new OFDictionary with the specified key and object. | |
(id) | + dictionaryWithObjects:forKeys: |
Creates a new OFDictionary with the specified keys and objects. | |
(id) | + dictionaryWithKeysAndObjects: |
Creates a new OFDictionary with the specified keys objects. |
An abstract class for storing objects in a dictionary.
Keys are copied and thus must conform to the OFCopying protocol.
Note: Fast enumeration on a dictionary enumerates through the keys of the dictionary.
- (OFArray *) allKeys |
Returns an array of all keys.
- (OFArray *) allObjects |
Returns an array of all objects.
- (BOOL) containsObjectIdenticalTo: | (id) | object |
Checks whether the dictionary contains an object with the specified address.
object | The object which is checked for being in the dictionary |
+ (id) dictionary |
Creates a new OFDictionary.
+ (id) dictionaryWithDictionary: | (OFDictionary*) | dictionary |
Creates a new OFDictionary with the specified dictionary.
dictionary | An OFDictionary |
+ (id) dictionaryWithKeysAndObjects: | (id) | firstKey | |
, | ... | ||
Creates a new OFDictionary with the specified keys objects.
firstKey | The first key |
+ (id) dictionaryWithObject: | (id) | object | |
forKey: | (id) | key | |
Creates a new OFDictionary with the specified key and object.
key | The key |
object | The object |
Creates a new OFDictionary with the specified keys and objects.
keys | An array of keys |
objects | An array of objects |
- (void) enumerateKeysAndObjectsUsingBlock: | (of_dictionary_enumeration_block_t) | block |
Executes a block for each key / object pair.
block | The block to execute for each key / object pair. |
- (OFDictionary *) filteredDictionaryUsingBlock: | (of_dictionary_filter_block_t) | block |
Creates a new dictionary, only containing the objects for which the block returns YES.
block | A block which determines if the object should be in the new dictionary |
- (id) init |
Initializes an already allocated OFDictionary.
Reimplemented from OFObject.
- (id) initWithDictionary: | (OFDictionary*) | dictionary |
Initializes an already allocated OFDictionary with the specified OFDictionary.
dictionary | An OFDictionary |
- (id) initWithKey: | (id) | firstKey | |
arguments: | (va_list) | arguments | |
Initializes an already allocated OFDictionary with the specified key and va_list.
firstKey | The first key |
arguments | A va_list of the other arguments |
- (id) initWithKeysAndObjects: | (id) | firstKey | |
, | ... | ||
Initializes an already allocated OFDictionary with the specified keys and objects.
firstKey | The first key |
- (id) initWithObject: | (id) | object | |
forKey: | (id) | key | |
Initializes an already allocated OFDictionary with the specified key and object.
key | The key |
object | The object |
Initializes an already allocated OFDictionary with the specified keys and objects.
keys | An array of keys |
objects | An array of objects |
- (OFEnumerator *) keyEnumerator |
Returns an OFEnumerator to enumerate through the dictionary's keys.
- (OFDictionary *) mappedDictionaryUsingBlock: | (of_dictionary_map_block_t) | block |
Creates a new dictionary, mapping each object using the specified block.
block | A block which maps an object for each object |
- (id) objectForKey: | (id) | key |
Returns the object for the given key or nil if the key was not found.
The returned object is not retained and autoreleased for performance reasons!
key | The key whose object should be returned |