我正在與MagicalRecord版本異常時2.0.7***在+的NSManagedObjectContext MR_defaultContext]斷言失敗試圖截斷
每當我啓動應用程序,它與此異常崩潰:
*** Assertion failure in +[NSManagedObjectContext MR_defaultContext]
我配置coredata這樣的:
在的appdelegate didFinishLaunchingWithOptions方法:
[MagicalRecord setupCoreDataStack];
在的appdelegate applicationWillTerminate:
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
[Song MR_truncateAllInContext:localContext];
我缺少的東西:
[MagicalRecord cleanUp];
我注意到崩潰只有當我試圖從實體截斷所有記錄發生?上面採用的方法是錯誤的?
編輯
在這條線上發生崩潰:
+ (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_;
}
}
在NSMnagedObjectContext + MagicalRecord.m文件
你連接了一個調試器嗎?它停在哪條線上? – borrrden
崩潰發生在'NSManagedObjectContext + MagicalRecord.m'文件上,請參閱我的更新 – Malloc
該行似乎很清楚,錯誤是沒有設置默認上下文。看看你的控制檯,並確保正在設置一個默認的上下文。請嘗試使用'setUpCoreDataStackWithStoreNamed:'代替。 – borrrden