This question is really looking for a specific class that I know exists, but cannot find.
A few weeks ago I read through an article outlining a helper class for using KVC - it let you encapsulate KVC subscriptions so that you could have multiple values being observed without having to go through the same hander method, and also made cleanup of the KVC observers safer (since KVC cleanup is really finicky and exception prone).
So, in responses I am looking for either that helper class I had run across before, or other examples of attempts to wrap KVC to make it safer and more palatable for general use.
I finally found what I was looking for, the key to searching was to look for examples of using KVO with blocks.
I found three interesting resources, which I'll present as a starting point - if anyone has others that are good please also answer.
The first link is the article I mentioned finding before. It has a great summary of the problems with KVO as it stands, and an interesting helper class that encapsulates a KVO session:
http://www.mikeash.com/pyblog/key-value-observing-done-right.html
The second is a simpler NSObject category that lets you pass in a block to be activated on a change notification:
http://blog.andymatuschak.org/post/156229939/kvo-blocks-block-callbacks-for-cocoa-observers
The last is another category on NSObject that uses a binding mechanism to add observation:
http://wirestorm.net/blog/2011/05/27/block-based-observation-with-kvo/
A more up-to-date implementation is facebook kvo implementation using block It added a NSObject Category to add a KVOController property on all objects. But then we should be more careful about the retain cycles problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With