init(keyPath:observedObject:options:expectedValue:)
Creates an expectation that the system fulfills when the value of the observed property changes to an expected value.
Declaration
convenience init(keyPath: KeyPath<T, V>, observedObject: T, options: NSKeyValueObservingOptions = [.initial, .new, .old], expectedValue: V)Parameters
- keyPath:
The key path for the observed property, relative to the observed object.
- observedObject:
The object to observe the key path on.
- options:
A combination of values that specify what to include in observation notifications. For possible values, see Nskeyvalueobservingoptions.
- expectedValue:
A value that the key path’s specified property must equal to fulfill the expectation.
Discussion
Use this initializer to create an expectation that observes changes on the observed object until the value of the property matches the expected value, fulfilling the expectation.