This is due to KVO = observation of key values. Make sure you call the function
object.addObserver(self, forKeyPath:..., options:..., context:...)
somewhere; what is your observer quo. This class will also override the function.
observeValue(forKeyPath:of:change:context:)
, , , "" "". , , , .
?
Swift 3
Swift 3 ( ), , removeObserver, . - deinit:
deinit {
object.removeObserver(self, forKeyPath:#keyPath(same.as.in.addObserver))
}
object , addObserver!
: https://cocoacasts.com/key-value-observing-kvo-and-swift-3/
Swift 4
, Swift 4/iOS 11 , : Swift 4, KVO-?
observValue :
var observer: NSKeyValueObservation? = foo.observe(\.value, options: [.new]) { (foo, change) in
print(change.newValue)
}
, :
, , , , , .
, , , , .