Instance Method

setValue:forKey:

Adds a given key-value pair to the dictionary.

Declaration

- (void)setValue:(ObjectType)value forKey:(NSString *)key;

Parameters

value

The value for key.

key

The key for value. Note that when using key-value coding, the key must be a string (see Accessing Object Properties).

Discussion

This method adds value and key to the dictionary using setObject:forKey:, unless value is nil in which case the method instead attempts to remove key using removeObjectForKey:.

See Also

Adding Entries to a Mutable Dictionary

- setObject:forKey:

Adds a given key-value pair to the dictionary.

- setObject:forKeyedSubscript:

Adds a given key-value pair to the dictionary.

- addEntriesFromDictionary:

Adds to the receiving dictionary the entries from another dictionary.

- setDictionary:

Sets the contents of the receiving dictionary to entries in a given dictionary.