Instance Method


Adds a given key-value pair to the dictionary.


func setObject(_ anObject: Any, forKey aKey: NSCopying)



The value for aKey. A strong reference to the object is maintained by the dictionary.


The key for value. The key is copied (using copy(with:); keys must conform to the NSCopying protocol). If aKey already exists in the dictionary, anObject takes its place.

See Also

Adding Entries to a Mutable Dictionary

func setValue(Any?, forKey: String)

Adds a given key-value pair to the dictionary.

func addEntries(from: [AnyHashable : Any])

Adds to the receiving dictionary the entries from another dictionary.

func setDictionary([AnyHashable : Any])

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