Re: Strategy for acting on changes in child objects?
Re: Strategy for acting on changes in child objects?
- Subject: Re: Strategy for acting on changes in child objects?
- From: Caleb Strockbine <email@hidden>
- Date: Thu, 07 May 2009 04:39:14 -0400
On May 7, 2009, at 2:21 AM, Graham Cox <email@hidden> wrote:
A. each observable object class exports a list of properties that it
thinks may be of interest to an observer. This is just an array of
strings (property names) returned by a class method.
B. A utility method iterates over that list and registers a nominated
observer against each one. There is also a complementary de-observing
method.
C. The observer calls the utility method on the child passing itself
as an observer.
Isn't that pretty much what +keyPathsForValuesAffectingValueForKey:
is for? The parent object could observe a single property, such as
'modified', and any children would implement either
+keyPathsForValuesAffectingValueForKey: or
+keyPathsForValuesAffectingModified to return the set of the
properties that would cause a child to be treated as modified. No
utility method needed -- KVO does it for you.
-Caleb
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden