【发布时间】:2017-02-27 07:53:12
【问题描述】:
我有这个来自 CoreData 的 UIManagedDocument 我正在正确使用。 . .
NSURL *localUrl = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
localUrl = [localUrl URLByAppendingPathComponent:@"Default Notes Database"];
//self.noteDatabase = [[UIManagedDocument alloc] initWithFileURL:localUrl]
现在我正在尝试在 iCloud 中保存核心数据的过程中创建 NSPersistentStore 实例。但是每当我尝试使用我的数据模型和 url 创建 NSPersistentStore 时,NSPersistentStore 总是为零。
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Notes" withExtension:@"momd"];
NSPersistentStoreCoordinator *migrationPSC = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]];
// Open the store
id sourceStore = [migrationPSC addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:iCloudUrl options:@{ NSPersistentStoreUbiquitousContentNameKey: @"InhoNotesiCloudStore",NSSQLitePragmasOption: @{@"journal_mode":@"DELETE"},NSMigratePersistentStoresAutomaticallyOption:@YES,NSInferMappingModelAutomaticallyOption:@YES } error:nil];
SourceStore 为零!为什么这是零?我搜索了答案,但在网上一无所获。
【问题讨论】: