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: Ken Tabb <email@hidden>
- Date: Mon, 22 Feb 2010 23:53:02 +0000
Hi Jerry,
thanks for the reply. You're right, implementing -setEmployees works
like a charm. There's no mention of it in the CoreData.pdf though,
that I can find.
I will try to use KVO observations, but my purpose is actually to
maintain a linked list of employees (OK the Department / Employee
analogy is breaking down here!).
Thanks again for the info, I'll meanwhile file a bug about the 10.6
documentation.
Cheers,
Ken
On 22 Feb 2010, at 11:21, Jerry Krinock wrote:
On 2010 Feb 22, at 14:59, Ken Tabb wrote:
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
I believe that Core Data does a wholesale replacement. Try
overriding -setEmployees: and see if that works. Just as if it were
a regular attribute. Something like this method I use:
- (void)setTriggers:(NSSet*)value {
[self postWillSetNewTriggers:value] ;
[self willChangeValueForKey:constKeyTriggers];
[self setPrimitiveTriggers:[NSMutableSet setWithSet:value]];
[self didChangeValueForKey:constKeyTriggers];
}
If this works, do not delete your other custom setters, because you
don't know how Core Data may decide to mutate the set in Mac OS
10.7. It's an "implementation detail".
Also, consider observing the value using KVO, instead of custom
setters.
- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Developer - Health & Human Sciences
Machine Vision & Neural Network researcher - School of Computer Science
University of Hertfordshire, UK
_______________________________________________
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