How to create custom merge policy in CoreData?

Since none of the predefined CoreData merge policies suit my needs, I would like to create my own.

I think this should be possible by subclassing NSMergePolicy, but it is not clear to me what do to exactly to resolve a NSMergeConflict in [NSMergePolicy resolveOptimisticLockingVersionConflicts:error:].


Could anybody provide some deeper explanation or sample code for this?

Replies

I think this is a documentation defect. resolveOptimisticLockingVersionConflicts:error: should work just like resolveConflicts:error: does--if your code resolves the issue (or if calling [super resolveOptimisticLockingVersionConflicts: error:] returned true, then return true. Otherwise return false.


But conflict resolution probably comes down to: First, double check that you really have to do anything, and avoid doing this if at all possible.