Re: Adding/removing managed objects: how to know the maximum 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