I am getting an exception with MagicalRecord version 2.0.7
whenever I launch the app, it crashes with this exception:
*** Assertion failure in +[NSManagedObjectContext MR_defaultContext]
I am configuring coredata like this:
In appdelegate didFinishLaunchingWithOptions method:
[MagicalRecord setupCoreDataStack];
In appdelegate applicationWillTerminate:
[MagicalRecord cleanUp];
I noticed the crash occurs only when I try to truncate all records from an entity:
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread]; [Song MR_truncateAllInContext:localContext];
Am I missing something? is the method adopted above wrong ?
Edit
The crash occurs on this line:
+ (NSManagedObjectContext *) MR_defaultContext { @synchronized (self) { NSAssert(defaultManagedObjectContext_ != nil, @"Default Context is nil! Did you forget to initialize the Core Data Stack?");//this line return defaultManagedObjectContext_; } }
In NSMnagedObjectContext+MagicalRecord.m file