If you saved the temporary MOC, then all you have to do is call -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:] on the main MOC with the save notification from the temporary MOC.
It's moving unsaved changes around that's cumbersome. - Ben > 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? _______________________________________________ Cocoa-dev mailing list ([email protected]) 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/archive%40mail-archive.com This email sent to [email protected]
