Re: Another basic CoreData question
Re: Another basic CoreData question
- Subject: Re: Another basic CoreData question
- From: "Sean McBride" <email@hidden>
- Date: Fri, 9 Jul 2010 10:26:27 -0400
- Organization: Rogue Research Inc.
On Fri, 9 Jul 2010 05:12:10 -0700, Jerry Krinock said:
>>> Using the standard Employee/Department example, Whats the best way to
>set a default department for an Employee?
>>> So that every employee is created with a relationship to the
>"mailRoom" department.
>>
>> Probably to add some custom code to AwakeFromInsert in your employee
>NSManagedObjectSubclass to set its own department.
>
>Yes, that works.
Agreed, but it can be tricky. How, from Employee's awakeFromInsert, do
you get the default Department? One way would be to fetch. I do this
and it's generally fine, except for a bug in NSArrayController:
6723165 fetching in awakeFromInsert causes 2 notifications to
NSArrayController
Looks like this is actually mentioned in awakeFromInsert's docs now. Nice!
So if you have a tableview (bound to an array controller) of Employees,
adding a new Employee will result in two items in the table (but not
your model).
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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