Instance Method

setObject(_:forKey:)

Adds a given key-value pair to the dictionary.

Declaration

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

Parameters

anObject

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

aKey

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.