When is watchValueForKeyPath called?

Does it get called after a property change (which means that the property setting tool is already popped out of the call stack) or when the property installer is running?

Swift is very convenient "Property observers". Does Obj-C have something similar for KVO?

+4
source share
2 answers

It depends on what options were used when adding an observer. If the observer was added using NSKeyValueObservingOptionPrior, then it -observeValueForKeyPath:...is called both before and after the property change. Or, more precisely, it was called both during -willChange...and during the methods -didChange....

NSKeyValueObservingOptionPrior , -observeValueForKeyPath:... . ( -didChange....)

Swift KVO. , ( ) - / , ( ).

, KVO , . , - , .

+3

All Articles