Core Data guidance Was: Calling processPendingChanges from awakeFromInsert
Core Data guidance Was: Calling processPendingChanges from awakeFromInsert
- Subject: Core Data guidance Was: Calling processPendingChanges from awakeFromInsert
- From: Brian Williams <email@hidden>
- Date: Thu, 20 Sep 2007 17:56:48 -0700 (PDT)
Have the core data docs people though about a section specifically explaining
what you should and shouldn't do when and where. Maybe in the context of the
object and document life cycles. Including the gotchas like the side effects of
undo redo etc... I really could have used some architecture guidance with my
first CD projects.
I am tempted to gather a list of such issues and post them somewhere as a "best
practices" guide. However it would be better if someone more qualified would
take on the job.
Brian
--- Tony Becker <email@hidden> wrote:
> Until the awakeFromInsert is finished, the object is "incomplete"
> Calling processPendingChanges flushes (effectively commits) this
> incomplete object to the DB (thats a bad thing)
> Then, after awakeFromInsert, the real object is inserted, which
> appears as a dupe.
>
> You must not call processPendingChanges in awakeFromInsert or
> awakeFromFetch.
> For the same reasons, you can't call executeFecthRequest (which calls
> processPendingChanges), in either of the same awake methods.
>
> Under various conditions, you'll get two objects - and have really
> strange undo problems (even if you don't call the undo registration
> code), which I suspect you're having.
>
> Call your undo registration code after the object is inserted into
> the context.
>
>
_______________________________________________
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