init(keyPath:object:)
Creates an expectation that any KVO change to the specified key path of the observed object fulfills.
Declaration
convenience init(keyPath: String, object: Any)Parameters
- keyPath:
The key path to observe.
- object:
The object to observe.
Discussion
This initializer sets up KVO observation for keyPath with the following NSKeyValueObservingOptions:
The inclusion of the new and old options means that any custom KVO handler you provide in the expectation’s handler property receives a change info dictionary that contains the doc://com.apple.documentation/documentation/foundation/nskeyvaluechangekey/newkey and doc://com.apple.documentation/documentation/foundation/nskeyvaluechangekey/oldkey keys.