Re: Merge changes between two Managed Object Contexts
Re: Merge changes between two Managed Object Contexts
- Subject: Re: Merge changes between two Managed Object Contexts
- From: Austin Grigg <email@hidden>
- Date: Sun, 21 Mar 2010 22:17:02 -0400
Thank you Joanna, that was very helpful. So, from your experience, mergeChangesFromContextDidSaveNotification: will not pick up adding a new object, just editing an existing one? It seems like the real pain point is having to re-create the new object in the second managedObjectContext and copy all it's properties.
Austin
On Mar 21, 2010, at 6:48 PM, Joanna Carter wrote:
> Hi Austin
>
>> I've got a Core Data project and I have a window controlled by an NSWindowController that is used to add or edit an NSManagedObject. I wanted to create a separate Managed Object Context in the NSWindowController so that the changes made to the object aren't seen by the UI below and so I can just throw away the changes if the user clicks "Cancel". If the user clicks "Save' I wanted to merge the changes from the temporary MOC to the main MOC being used by the rest of the application.
>>
>> What is the best way to merge those changes back to the main MOC? Do I have to recreate the object in the main MOC as is done in this example: http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data? Or, can I use - (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag to merge the changes? If i use refreshObject:mergeChanges, can I pass it my NSManagedObject from the temporary MOC and do I need to call save: on the temporary MOC before doing that?
>
> I have created a basic tutorial that demonstrates both adding and editing and object. AFAICT, you need to take two different approaches. The tutorial is available at http://www.richplum.co.uk/magazine/dg201001.pdf
>
> Joanna
>
> --
> Joanna Carter
> Carter Consulting
>
_______________________________________________
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