On May 14, 2012, at 9:02 AM, Quincey Morris <[email protected]> wrote:
> On May 14, 2012, at 08:40 , Kyle Sluder wrote: > >> On May 14, 2012, at 1:06 AM, Quincey Morris >> <[email protected]> wrote: >> >>> 2. Check the KVO compliance of whichever of these keys you use. For >>> example, a leaf key like this: >>> >>> - (BOOL) isLeaf { >>> return self.properties.count > 0; >>> } >>> >>> *isn't* KVO compliant. >> >> Hmm? As long as you return a set containing "properties" from >> +keyPathsAffectingIsLeaf, and your class is KVO compliant for "properties", >> this should also be KVO compliant. > > That was my point, the "naked" isLeaf method isn't KVO compliant unless you > supplement it with something like keyPathsAffectingIsLeaf. > > Note that the set should return "properties.count" (not "properties"), and > the class should be KVO compliant for both "properties" AND "count". If properties is a collection type—NSArray, NSSet, or (as I understand it) NSOrderedSet)—then it is necessary and sufficient to only return "properties." These classes are not KVO-compliant for the key "count," and any KVO-compliant change to the "properties" key will generate the correct KVO notifications. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
