Instance Method

removeObserver(_:forKeyPath:)

Stops the observer object from receiving change notifications for the property specified by the key path relative to the object receiving this message.

Declaration

func removeObserver(_ observer: NSObject, forKeyPath keyPath: String)

Parameters

observer

The object to remove as an observer.

keyPath

A key-path, relative to the object receiving this message, for which observer is registered to receive KVO change notifications.

Discussion

It is an error to call removeObserver(_:forKeyPath:) for an object that has not previously been registered as an observer.

Be sure to invoke this method (or removeObserver(_:forKeyPath:context:)) before any object specified in addObserver(_:forKeyPath:options:context:) is deallocated.

See Also

Related Symbols

func addObserver(NSObject, forKeyPath: String, options: NSKeyValueObservingOptions = [], context: UnsafeMutableRawPointer?)

Registers the observer object to receive KVO notifications for the key path relative to the object receiving this message.