Note that there are some explanatory texts on larger screens.

plurals
  1. PONSMergeConflict for NSManagedObject
    primarykey
    data
    text
    <p>I execute multiple requests asynchronously and each response returns an xml. I need to extract the xml (I’m using TBXML to parse it) and save it in Core Data. This cannot be done on the main thread because the UI will get too slow. I’m doing the following for each xml response:</p> <pre><code>dispatch_queue_t request_queue = dispatch_queue_create("com.queue.name", NULL); dispatch_async(request_queue, ^{ AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *newMOC = [[NSManagedObjectContext alloc] init]; [newMOC setPersistentStoreCoordinator:[appDelegate persistentStoreCoordinator]]; newMOC setUndoManager:nil]; NSNotificationCenter *notify = [NSNotificationCenter defaultCenter]; [notify addObserver:self selector:@selector(mergeChanges:) name:NSManagedObjectContextDidSaveNotification object:newMOC]; [self traverseElement:tbxml.rootXMLElement inMOC:newMOC]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:newMOC]; [newMOC release]; }); dispatch_release(request_queue); - (void)mergeChanges:(NSNotification*)notification { AppDelegate *theDelegate = [[UIApplication sharedApplication] delegate]; [[theDelegate managedObjectContext] performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:) withObject:notification waitUntilDone:YES]; </code></pre> <p>}</p> <p>In the traverseElement method, I parse the xml and insert the data in Core Data. I’m getting a lot of merge conflicts like the one below when executing this. Any ideas why or any clues to debug this issue? I haven’t changed the Core Data model.</p> <pre><code>NSMergeConflict for NSManagedObject with objectID '...' with oldVersion = 117 and newVersion = 118 and old object snapshot = ... and new cached row = ... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload