KVO+Blocks
Just found out this little NSObject category. It’s awesome. A must #include in your project.
“To get observation notices, you have to override a lengthy selector (observeValueForKeyPath:ofObject:change:context:), provide a static context pointer, and essentially implement a big switch statement on the key path.
That’s unwieldy, but I think it also makes for unmaintainable code: the callbacks end up thrown in the same method, and they’re separated from the observer registration.”
~ KVO+Blocks: Block Callbacks for Cocoa Observers
Since iOS 4 support blocks, it’s possible to use this for iPhone projects too.
Leave a Reply