• 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: CoreData "Could Not Merge Changes"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData "Could Not Merge Changes"


  • Subject: Re: CoreData "Could Not Merge Changes"
  • From: Jesse Grosjean <email@hidden>
  • Date: Sun, 14 Aug 2005 09:00:03 -0400

I'm getting a "Could not merge changes" error, the documentation says that this error is caused when two different managed object contexts try to change the same data. But in my case I only have a single managed object context. I can recreate the error this way:

I can reproduce the problem here (but haven't tried it in a trivial sample). Looking at the information in the error it isn't immediately obvious to me why it is failing.

I've put up a simple example project to demonstrate this problem. It's attached to this posting:


    http://www.hogbaysoftware.com/beta/node/189

To reproduce the "Could Not Merge Changes" problem you should do this:

1. Add new person
2. Set name for new person
3. Save document
4. Undo twice, so that the name is unset and the person is removed
5. Save document
6. Redo once so the person is again added, but name is not set.
7. Now try to save and you will see a "Could Not Merge Changes" error.

Here's what the conflicList looks like in the NSError that results from trying to save:

po *error
NSError "Could not merge changes." Domain=NSCocoaErrorDomain Code=133020 UserInfo={
conflictList = (
{
cachedRow = {};
newVersion = 0;
object = <NSManagedObject: 0x3afab0> (entity: Person; id: 0x3d2e60 <x-coredata://92402FCC-6054-44E6-BEFF-B5C24409778C/ Person/p1> ; data: {name = nil; });
oldVersion = 0;
snapshot = {name = <null>; };
}
);
}


I'm not sure how to read that, but it looks odd that both the new and old version have the same version number.

In my first posting I said that setting a merge policy would fix the problem, but that isn't really the case. Setting a merge policy gets rid of the save error, but it loses information from the redo stack in the process. You can reproduce that problem by setting a merge policy on the managed object context and then do this:

1. Add new person
2. Set name for new person
3. Save document
4. Undo twice, so that the name is unset and the person is removed
5. Save document
6. Redo once so the person is again added, but name is not set.
7. Save document (no error this time since merge policy is set)
8. Now try to redo again so that the name will be set, but the redo fails and it appears the name has been lost from the redo stack.


So now I'm not sure how to get around this problem. I'm guessing that I'll need to catch this error condition and then manually patch up the managed object context before saving again. But so far I haven't figured out what to patch.

Jesse
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CoreData "Could Not Merge Changes"
      • From: mmalcolm crawford <email@hidden>
References: 
 >CoreData "Could Not Merge Changes" (From: Jesse Grosjean <email@hidden>)
 >Re: CoreData "Could Not Merge Changes" (From: Jim Correia <email@hidden>)

  • Prev by Date: Sync services notification
  • Next by Date: Re: Core Data and multiple NIBs: how to share the managedObjectContext?
  • Previous by thread: Re: CoreData "Could Not Merge Changes"
  • Next by thread: Re: CoreData "Could Not Merge Changes"
  • Index(es):
    • Date
    • Thread