• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Merge changes between two Managed Object Contexts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Merge changes between two Managed Object Contexts


  • Subject: Re: Merge changes between two Managed Object Contexts
  • From: Ben Trumbull <email@hidden>
  • Date: Tue, 23 Mar 2010 12:34:20 -0700

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@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

  • Prev by Date: Re: How to hide new objects in a NSTableView?
  • Next by Date: Re: find panel buttons not enabling
  • Previous by thread: Re: Merge changes between two Managed Object Contexts
  • Next by thread: Odd crash
  • Index(es):
    • Date
    • Thread