删除CoreData日记模式不迁移到新的商店
问题描述:
由于MagicalRecord 3.0还没有发布,我升级到2.3,并试图“关闭”日志模式。这是我的代码:删除CoreData日记模式不迁移到新的商店
// Code to disable journaling mode
NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
NSString *applicationDocumentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *urlString = [applicationDocumentsDirectory stringByAppendingPathComponent: @"saori.sqlite"];
NSURL *url = [NSURL fileURLWithPath:urlString];
NSDictionary *options = @{NSSQLitePragmasOption:@{@"journal_mode":@"DELETE"}};
NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel];
[psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:options error:nil];
发生了什么事是它不仅没有关闭日志模式,但它创造了一个全新的(读空)CoreData店与日志。
在MR 3.0之外有什么可以做的,因此日志存储的内容会迁移到新的CoreData存储而不记录?
答
MagicalRecord 3.0不会改变它是否有效。这是一个CoreData功能。 MR 3.0将为您提供一种指定添加特定商店的选项的方法,因此它的代码更少。但是Journalling或WAL模式是一个问题,这对于CoreData本身的工作原理是很重要的。在那种情况下,转移到MR3可能不会帮助你。
谢谢Saul ......我会重写这个问题并重新发布...... – SpokaneDude