Mention strongly-typed change object for observation

This commit is contained in:
Sindre Sorhus 2019-05-09 18:08:18 +07:00
parent 12eedf762b
commit 33f21390bc
1 changed files with 2 additions and 0 deletions

View File

@ -173,6 +173,8 @@ let observer = defaults.observe(.isUnicornMode) { change in
defaults[.isUnicornMode] = true defaults[.isUnicornMode] = true
``` ```
In contrast to the native `UserDefaults` key observation, here you receive a strongly-typed change object.
### Default values are registered with UserDefaults ### Default values are registered with UserDefaults
When you create a `Defaults.Key`, it automatically registers the `default` value with normal UserDefaults. This means you can make use of the default value in, for example, bindings in Interface Builder. When you create a `Defaults.Key`, it automatically registers the `default` value with normal UserDefaults. This means you can make use of the default value in, for example, bindings in Interface Builder.