Core-Data : how to merge two contexts ?
Core-Data : how to merge two contexts ?
- Subject: Core-Data : how to merge two contexts ?
- From: Eric Morand <email@hidden>
- Date: Fri, 06 Nov 2009 17:09:41 +0100
Hi guys,
Apple keeps on talking about Core-Data managed object contexts as
"scratchpads". I'm trying to use them as such but face a lot of
problem when it comes to merge contexts between each others once I
want to "submit" the modifications that lies in the scratchpad.
For example, let say that I want to be able to use a new context to
deal with the creation of a new "product". I create a new editing
context, insert a new product, open a new window and let the user fill
the fields and click on Submit or Cancel. If the user clicks on
Cancel, I release the editing context, if the user clicks on submit, I
want to merge it with the 'main' context. That's where I'm stuck : how
am I supposed to merge both contexts ?
I've found a method called mergeChangesFromContextDidSaveNotification:
that is supposed to do this but it can only be called when the editing
context is saved - in other words, when the changes are committed into
the persistent store. The problem is that it makes no sense at all to
save the document each time the user add a new product ! I don't want
that, my users don't want that, nobody wants that : the user is
responsible for saving its document (may it be with an auto-saving
feature or manual saving), not the developer !
Is there a way to merge changes from one "editing" context into
another without having to save the editing context first ?
Thanks for your help and advices,
Eric.
_______________________________________________
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