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 参照

Registering for Observation