Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.