Recovering from a merge conflict
Recovering from a merge conflict
- Subject: Recovering from a merge conflict
- From: Paulo Andrade <email@hidden>
- Date: Tue, 21 Dec 2010 14:36:21 +0000
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 (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