Re: Core Data: Custom to-many relationship setter not being invoked
Re: Core Data: Custom to-many relationship setter not being invoked
- Subject: Re: Core Data: Custom to-many relationship setter not being invoked
- From: mmalc Crawford <email@hidden>
- Date: Tue, 23 Feb 2010 13:17:37 -0800
On Feb 22, 2010, at 2:59 pm, Ken Tabb wrote:
> Distilling my problem down into the Department & Employees example, both are custom NSManagedObject subclasses, each with an inverse to-many / to-one relationship as you'd expect. My problem is that Department's custom -awakeFromInsert gets called, yet its -addEmployeesObject and -addEmployees methods don't ever get called. If I add employees in the app, it all works swimmingly, but my custom accessors aren't ever used.
>
<http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdTroubleshooting.html#//apple_ref/doc/uid/TP40002320-SW3>
Custom relationship set mutator methods are not invoked by an array controller
Problem: You have implemented set mutator methods for a relationship as described in “Custom To-Many Relationship Accessor Methods,” and have bound thecontentSet binding of an NSArrayController instance to a relationship (as illustrated by the Employees array controller in NSPersistentDocument Core Data Tutorial), but the set mutator methods are not invoked when you add objects to and remove objects from the array controller.
Cause: This is a bug.
Remedy: You can work around this by adding self to the contentSet binding's key path. For example, instead of binding to [Department Object Controller].selection.employees, you would bind to [Department Object Controller].selection.self.employees.
mmalc
_______________________________________________
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