Type Method
replace(_:observe:forKeyPath:withObserver:options:context:) replaceObservation:observe:forKeyPath:withObserver:options:context: replaceObservation_observe_forKeyPath_withObserver_options_context_
Replaces an existing observation with a new observation.
Declaration
class func replace(_ observation: UnsafeMutablePointer<GSKeyValueObservation?>, observe object: NSObject?, forKeyPath keyPath: String, withObserver observer: NSObject, options: NSKeyValueObservingOptions = [], context: UnsafeMutableRawPointer?)Declaration
+ (void) replaceObservation:(GSKeyValueObservation **) observation observe:(NSObject *) object forKeyPath:(NSString *) keyPath withObserver:(NSObject *) observer options:(NSKeyValueObservingOptions) options context:(void *) context;Declaration
replaceObservation_observe_forKeyPath_withObserver_options_context_(object: NSObject, keyPath: str, observer: NSObject, options: NSKeyValueObservingOptions, context) -> GSKeyValueObservationParameters
observationA pointer to the observation to stop and then replace. Can be a pointer to
nilwhen no current observation exists.observerWhen
nil, stops the observation.
Discussion
This is a thin wrapper around observe(_:observation ended. Simply replacing the existing observation with the new observation, as shown in the example from observe(_:
- (void)thingDidUpdate:(Thing *)newThing {
[GSKeyValueObservation replaceObservation:&_someObservation observe:newThing ...];
}