Re: Changing the model behind contoller's back?
Re: Changing the model behind contoller's back?
- Subject: Re: Changing the model behind contoller's back?
- From: "Oleg Krupnov" <email@hidden>
- Date: Fri, 5 Sep 2008 12:21:21 +0300
> For a Core Data to-many property, which is implemented as a NSMutableSet, you can use:
>[employee mutableSetValueForKey:@"directReports"]
> as a KVO-compliant set proxy, and send it any messages you would normally send to a set, such as addObject: or removeObject: or removeAllObjects or whatever. (I assume you already know that something like [employee.directReports addObject: value] is *not* KVO- compliant. It'll update the relationship, but not trigger notifications to observers of the "directReports" property.)
> The dynamic accessors are KVO-compliant convenience methods you can use instead. addDirectReportsObject: is functionally equivalent to [[employee mutableSetValueForKey:@"directReports"] addObject: value], and removeDirectReportsObject: is functionally equivalent to [[employee mutableSetValueForKey:@"directReports"] removeObject: value].
> Possibly these dynamic accessors are a bit more efficient, or perhaps they use mutableSetValueForKey:, I don't really know, but it's generally a good idea to use the features that Core Data gives you, if you can.
This is exactly my understanding. The problem is however that when I call
[rootWidget mutableSetValueForKey:@"childWidgets"] addObject:newWidget];
or
[rootWirdget addChildWidgetsObject:newWidget];
the NSTreeController bound to the model does NOT send a change message
to the custom view bound to the controller. It does only when I modify
the model via the controller.
What can be the problem here?
_______________________________________________
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