Instance Method

objectForKeyedSubscript:

Returns the value associated with a given key.

Declaration

- (ObjectType)objectForKeyedSubscript:(KeyType)key;

Parameters

key

The key for which to return the corresponding value.

Return Value

The value associated with key, or nil if no value is associated with aKey.

Discussion

This method has the same behavior as the objectForKey: method.

You shouldn’t need to call this method directly. Instead, this method is called when accessing an object by key using subscripting.

id value = dictionary[@"key"]; // equivalent to [dictionary objectForKeyedSubscript:@"key"]

See Also

Accessing Keys and Values

allKeys

A new array containing the dictionary’s keys, or an empty array if the dictionary has no entries.

- allKeysForObject:

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

allValues

A new array containing the dictionary’s values, or an empty array if the dictionary has no entries.

- valueForKey:

Returns the value associated with a given key.

- getObjects:andKeys:count:

Returns by reference C arrays of the keys and values in the dictionary.

- getObjects:andKeys:

Returns by reference C arrays of the keys and values in the dictionary.

Deprecated
- objectsForKeys:notFoundMarker:

Returns as a static array the set of objects from the dictionary that corresponds to the specified keys.

- objectForKey:

Returns the value associated with a given key.