Open fysteven opened 8 years ago
I got the pretty same error in my application. Any suggestions what could it be?
+1
+1
+1
+1 (Mac)
+1
+1
+1
+1
+1
Just wondering if any leads or ideas have been made regarding what might cause this issue.
+1 ,anyone have resovled,please share it .
any news about this error?
Most of the time, it's due to rootSavingContext
set to nil in cleanup
method when app being terminated (I suppose you're all calling [MagicalRecord cleanUp];
in - (void)applicationWillTerminate:(UIApplication *)application
). So when creating a local context in non-main thread, this error happens.
You can check the stack of your main thread to confirm if the app is terminating. If so:
rootSavingContext
is nil
first, if it's nil
, just return nothing, or call the error callback. Then you also need to better handle this nothing or error state.
2.2 If you have some important tasks in background, e.g. saving data, you'd better wait for them done in applicationWillTerminate
method. But do remember that, you have at most ~5 seconds to perform tasks in applicationWillTerminate
method.
Fatal Exception: NSInvalidArgumentException Parent NSManagedObjectContext must not be nil.
NSManagedObjectContext+MagicalRecord.m line 68 +[NSManagedObjectContext(MagicalRecord) MR_contextWithParent:]