Contents

set(_:forKey:)

Sets the value of the specified key to a property list object.

Declaration

func set(_ value: Any?, forKey defaultName: String)

Parameters

  • value:

    The property-list type to store in the defaults database. If you specify an array or dictionary type, those collections must similarly contain only property list types.

  • defaultName:

    The key that contains the setting’s name.

Discussion

Use this method to write property list object types to the defaults store. To store types that aren’t property list objects, archive them to a Data object and use this method to save that data object to the defaults store.

After you call this method, the system generates a didChangeNotification for registered observers.

See Also

Setting the value for a key