| Shameless plug.
Here's mine
https://github.com/seivan/SHKeyValueObserverBlocks#adding-ob... Comes with bi- and uni-bindings.
I like mine better but I wouldn't have done the auto-removal of observers without Yan Raboviks swizzling magic https://github.com/rabovik/RSSwizzle credits due. I set a toggle in case you feel that's too dangerous to shut it off - Something I use. I compared a couple of ways of dealing with that, including writing some of my own and I think Yan does it the best. When doing my own I had some discussions with James Montgomerie regarding race conditions and dealing with class hierarchies. He had solved with a different way here himself: https://github.com/th-in-gs/THObserversAndBinders Here's the discussions between us regarding the swizzling magic (that Facebook also does here)
https://github.com/th-in-gs/THObserversAndBinders/commit/a4c... The pull requests leading up to me going with Raboviks library (due to better code and smarter implementation) Test for infinite loop when deallocating:
https://github.com/seivan/SHKeyValueObserverBlocks/pull/5 New test to ensure dealloc of observed objects runs:
https://github.com/seivan/SHKeyValueObserverBlocks/pull/2 |
We use a shared controller instance, that acts as a receptionist for all KVO notifications, as well as a weak reference to the observer, in order to safely allow observer removal on dealloc.