Hello,

I have an application using Core Data that has to import/update some data to/in 
the database.

It imports in batches and it conflict may happen. Some object being updated in 
a batch might also be updated in another context.

This is fine and I'm aware that this will happen. What I want to do is start 
this batch from the beginning.

The problem is that I cannot make NSManagedObjectContext forget about the merge 
error!

The code is something like this
===

// at this point all [moc hasChanges] is NO

int tries = 10;
while ( tries-- ) {
        // compute this batch

  [moc save:&error];
  if (error != nil && [error code] == NSManagedObjectMergeError) {
   [moc rollback];
   NSLog(@"Got optimistic locking error %...@\n. Retrying...", [error 
description]);
   continue;
  } else {
   break;
  }
}
==

It seems rollback isn't enough, iterating over [moc updatedObjects] and calling 
refreshChanges:mergeObject: also doesn't work.


1- So how can I mark a conflict as resolved?

2- Why is the NSMergeConflict object private? Is the only way to find which 
object caused the error is to print that object and look at that message?


_______________________________________________

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

Reply via email to