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 (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com