Re: Another basic CoreData question
Re: Another basic CoreData question
- Subject: Re: Another basic CoreData question
- From: Jerry Krinock <email@hidden>
- Date: Fri, 9 Jul 2010 05:12:10 -0700
On 2010 Jul 08, at 19:28, Noah Desch wrote:
> On Jul 8, 2010, at 7:33 PM, email@hidden wrote:
>
>> 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. As always, you must be careful you don't screw up Undo. For discussion of this, see list archives during the last couple weeks, thread:
Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
Several solutions are given. Gumboots asked which is "best". I don't know. They all work.
An interesting question is how this happens in the DepartmentAndEmployees sample code. When I create a document with an employee, save the file and dump it with sqlite3, it appears that the Employee is related to the Department. But I looked at that code for a few minutes yesterday and can't see how it happened. The only time that an Employee is set to a Department or vice versa is in the -paste method, but that doesn't run. Does anyone know?
_______________________________________________
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