I've done some simple KVO setups. Now I have a bit more complex one. I have a singleton object that is settable. That is reachable with code like
[Site singleton].value
I can (and have) watch that singleton for changes in it's value property. But I would also like to watch a property of the current value (IF it's not nil). It has a valves property that I would like to notice changes in.
Without knowing any better, I guess I can do something like
- Observe the
valueproperty like I'm used to - When that changes, register a watch on the current value's
valvesproperty as well IF it is non nil - Also, somehow, not sure how to do this, unregister any
valveswatching it was doing on the previousvalue.
This seems... burdensome.
I see that you can do more complex keyPaths but I've not found documentation that explains how to use them. Are they something that could make this problem easier? If not, is this a pattern that others have found a good solution for?