I am having real difficulties resolving this issue when migrating my App from iOS7 to iOS8, the app works perfect on iOS7.
It crashes when I am trying to save
NSError *error = nil;
if (![managedObjectContext save:&error]) { <---- crashes here
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}
I've seen only 2 similar issues on stackoverflow but none of the responses were relevant to my problem.
iOS 8 CoreData Issue: recordChangeSnapshot:forObjectID:: global ID may not be temporary when recording
iOS 8 Core Data Issue: global ID may not be temporary when recording
Its not easy to post all the code. I don't know where to begin debugging !, some help please. Thanks
Is this call to [managedObjectContext save:&error]
happening on a background thread? Is it usually called on the main thread?
The pattern recommended for concurrent programming with Core Data is thread confinement: each thread must have its own entirely private managed object context.
When working with your Core Data code, you can use isMainThread
to determine if you're on a background thread and switch to the main thread prior to working with Core Data:
- (void)yourCoreDataTask {
if (![[NSThread currentThread] isMainThread]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self yourCoreDataTask];
});
return;
}
// Now on the Main Thread. Work with Core Data safely.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With