在保存對象時,我遇到了使用MagicalRecord時出現的問題。在保存對象時執行使用MagicalRecord時出現錯誤訪問
節約使用上下文:
- (void)saveContext {
[[NSManagedObjectContext defaultContext] saveToPersistentStoreWithCompletion:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"You successfully saved your context.");
} else if (error) {
NSLog(@"Error saving context: %@", error.description);
}
}];
}
這個原因導致我的應用程序隨機崩潰,並EXEC_BAD_ACCESS上[[self MR_defaultContext] mergeChangesFromContextDidSaveNotification:notification];
我用另一種方法:
//get correct order based on indexPath
Order *orderToComplete = [self objectInOrdersAtIndex:indexPath.section];
//set order as completed
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext)
{
Order *localOrder = [orderToComplete inContext:localContext];
[localOrder setIsCompletedValue:YES];
}completion:^(BOOL success, NSError *error)
{
if(success)
NSLog(@"You successfully saved your context.");
else
NSLog(@"Error saving context: %@", error.description);
}];
但還是隨機崩潰。
我的應用程序不是多線程的應用程序。 這裏是一個鏡頭:
有沒有人有任何想法?
具有相同的問題。你解決了嗎? – 2014-11-22 18:55:56