On 16 Nov 2012, at 22:00, Rick Mann <[email protected]> wrote:
>
> On Nov 16, 2012, at 2:31 , Mike Abdullah <[email protected]> wrote:
>
>> Why are you trying to avoid "a bunch of" these calls? Is it just to save
>> yourself typing?
>
> Typing, and code maintenance. I generally have UI that displays all (or some
> subset of) the properties of one of my entities. I'd like that UI to update
> if anything updates one of the models. But if there are a dozen properties,
> then that's a dozen -addObserver and -removeObserver calls, in each place
> where there might be UI associated with it. If I later add a new property to
> the entity, I have to be sure to KVO, it, too. If I remove a bit of the UI, I
> have to remember to remove the call (not strictly, but I like keeping my code
> clean).
>
> Being able to subscribe once for all changes to a single object makes these
> problems go away.
This is Core Data. You have all the information available to you automatically:
NSEntity *entity = [someManagedObject entity];
for (NSPropertyDescription *aProperty in [entity properties])
{
[someManagedObject addObserver:self forKeyPath:[aProperty name] …
}
Obviously you can adjust that snippet to focus on just attributes, or skip some
out, as desired.
_______________________________________________
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]