On Oct 6, 2011, at 4:12 PM, Kyle Sluder wrote: > On Thu, Oct 6, 2011 at 12:33 PM, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: [...] >> Note, however, that because the observer mechanism is so clunky, you're >> going to write *more* lines of code this way than in overriding the setter, >> yet all it buys you is the unwanted/unnecessary "atomic" implementation. > > Not necessarily. If you expect subclasses to add properties that > require poking -setNeedsDisplay:, or you just have a lot of them, it's > probably worth adding a class method like +keyPathsRequiringRedisplay, > register as self-observers for all these keypaths, and provide a > really simple implementation of -observeValueForKeyPath:… that calls > [self setNeedsDisplay].
This is what the code I dashed off this morning does (or at least intends to do), except it puts the clunky KVO code into a separate convenience class that you can drop into any project. I just now cleaned up some silly mistakes and stole Kyle's "keyPathsRequiringRedisplay" name, though it still isn't perfect (see the description) and totally untested. <https://gist.github.com/1267594> --Andy _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com