According to Apple's own recommendations, when setting up KVC / KVO-compatible accessories manually, you must enable the BOTH KVO willChangeand didChange. This is what I did in all of my manual access methods.
However, it observeValueForKeyPath:ofObject:change:contextis called for each half of the KVC methods (will and will be) with exactly the same dictionary content.
When registering an observer using the option: the NSKeyValueObservingOptionPriorobserver is still called twice - once for each half - and, again, with the same dictionary contents, save only the difference that the "notificationIsPrior" key is included in the dictionary.
Now that KVO is used to change the attributes of an “expensive processor” —for example, to change color or redraw a large and thoughtful design, it makes sense to act only on “didChange” and ignore (or at least highlight) “willChange”. I used to achieve this by converting the key string to an enumeration list item that returns “1” shifted to the left, and used this digit to set the flag to a 32 or 64-bit integer when receiving the first call and when the reset flag in the second, I perform operations CPU intensive use (s).
However, it seems to me that this is a non-trivial implementation overhead for each case. Does anyone have any other "preferred" way to distinguish between a callback for "willChange" and "forChange" without allowing the same processing to be done twice?
I looked through my own Apple documentation, and this help group is plentiful for alteranatives, but Apple's own document does not actually contain details on this, and several people in this group also struggled with a similar problem. In both cases, no final decision was proposed. If someone knows a better way - besides avoiding 'willChange' using alternating flags - I would really appreciate it. (Why can't Apple include the “phase” key in the change dictionary ???)