init(keyPath:observedObject:options:predicate:)
Creates an expectation that the system fulfills when the value of the observed property changes and satisfies the conditions of a predicate’s evaluation.
Declaration
convenience init(keyPath: KeyPath<T, V>, observedObject: T, options: NSKeyValueObservingOptions = [.initial, .new, .old], predicate: XCTKeyPathExpectation<T, V>.Predicate? = nil)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.
- predicate:
A closure that evaluates the value of the observed property. If
nil, the first observed change fulfills the expectation.
Discussion
Use this initializer to create an expectation that observes changes on the observed object until the predicate returns true, fulfilling the expectation.