setObject(_:forKey:)
Adds a given key-value pair to the dictionary.
Declaration
func setObject(_ anObject: Any, forKey aKey: any 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 theNSCopyingprotocol). IfaKeyalready exists in the dictionary,anObjecttakes its place.