• 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: "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

  • Follow-Ups:
    • Re: Another basic CoreData question
      • From: email@hidden
References: 
 >Another basic CoreData question (From: email@hidden)
 >Re: Another basic CoreData question (From: Noah Desch <email@hidden>)
 >Re: Another basic CoreData question (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Another basic CoreData question
  • Next by Date: CIFilter does not strongly reference its name, resulting in crash when using garbage collection
  • Previous by thread: Re: Another basic CoreData question
  • Next by thread: Re: Another basic CoreData question
  • Index(es):
    • Date
    • Thread