[Mac src] Key Value Coding Additions

2 views
Skip to first unread message

Devin Lane

unread,
Apr 14, 2009, 7:54:43 AM4/14/09
to Mac Free Source Announcements
Basically I wrote this to simplify the use of Key Value Observing.
Instead of catching change notifications in a single -
observeValueForKeyPath:ofObject:change:context: method, you can
receive change notifications via a specific method call, as you can
with NSNotifications.

Benefits:
- No need to worry about the super-class implementation. (caveat: you
can still have method name collision here, be careful when naming your
observation handler methods in commonly used superclasses.)
- No need to check the key and context to see if the notification was
meant for you.
- Use simple observation handler methods when you don't care about all
change parameters.

More details, including API information is available here:
http://shiftedbits.org/2008/07/24/key-value-observing-improvements/#more-23

Checkout the code from subversion here: http://svn.shiftedbits.org/public/KVOAdditions/trunk/
Download a zip here: http://shiftedbits.org/static/KVOAdditions.zip

The license is currently the beer-ware license, but I can change it to
MIT/BSD if that's useful.

Finally, one known issue:
- In the GC case, observers are not removed. While I don't get a
warning for this as you do in the non-GC case, a mailing list post
(http://www.cocoabuilder.com/archive/message/cocoa/2007/11/8/192648)
indicates that these observers must still be removed. If anyone wants
to use this in the GC case, please let me know and I'll see what I can
do about making that work.
Reply all
Reply to author
Forward
0 new messages