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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software