If specified, a notification should be sent to the observer immediately, before the observer registration method even returns.
SDKs
- iOS 2.0+
- macOS 10.5+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
static var initial: NSKey Value Observing Options { get }
Discussion
The change dictionary in the notification will always contain an new
entry if new
is also specified but will never contain an old
entry. (In an initial notification the current value of the observed property may be old, but it's new to the observer.) You can use this option instead of explicitly invoking, at the same time, code that is also invoked by the observer's observe
method. When this option is used withadd
a notification will be sent for each indexed object to which the observer is being added.