• 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: Adding/removing managed objects: how to know the maximum index?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding/removing managed objects: how to know the maximum index?


  • Subject: Re: Adding/removing managed objects: how to know the maximum index?
  • From: Jim Correia <email@hidden>
  • Date: Sun, 25 Nov 2007 21:36:54 -0500

On Nov 14, 2007, at 5:47 PM, Arthur C. wrote:

My Core Data managed objects (instances) all have their own index. Naturally, when I add an object, I want to set its index to the highest index value so far, + 1. This should be done in - awakeFromInsert.
However, when I perform a fetch request from there, a second (new) item appears in the table (instead of just one). This can't be right.

See the documentation at:

<http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html >

See the section "Methods to Override Considerations". - initWithEntity:insertIntoManagedObjectContext: is listed as a method which cannot have side effects on the context; you cannot fetch or save from it. -awakeFromInsert is called from in that same call stack, so fetching from awakeFromInsert is probably also not allowed.

I've filed a bug asking for doc clarification.

Jim
_______________________________________________

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


References: 
 >Adding/removing managed objects: how to know the maximum index? (From: Arthur C. <email@hidden>)

  • Prev by Date: Re: NSObject's bind:toObject:forKeyPath:options
  • Next by Date: Re: Newbie question: NSDocument and standard file formats
  • Previous by thread: Re: Adding/removing managed objects: how to know the maximum index?
  • Next by thread: File system visiblilty
  • Index(es):
    • Date
    • Thread