• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Another basic CoreData question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Another basic CoreData question
      • From: "Sean McBride" <email@hidden>
    • Re: Another basic CoreData question
      • From: Keary Suska <email@hidden>
References: 
 >Another basic CoreData question (From: email@hidden)
 >Re: Another basic CoreData question (From: Noah Desch <email@hidden>)

  • Prev by Date: Re: [iPhone] Terminating iPhone App programatically
  • Next by Date: Re: NSXMLParser parses line feeds in attribute strings as spaces
  • Previous by thread: Re: Another basic CoreData question
  • Next by thread: Re: Another basic CoreData question
  • Index(es):
    • Date
    • Thread