我试图在iCloud中创建核心数据存储,但是当我第一次尝试添加持久存储(期待创建)时,我收到错误...
' - [__ NSCFDictionary setObject:forKey:]:尝试插入nil键'
我已经看过其他几个类似的帖子,但这些建议已经在我的代码中了。这是我的代码片段。
// set options
NSURL *ubiquitousContentURL = [ubiq URLByAppendingPathComponent:@"TransactionLogs"];
NSString *storeUbiquitousContentName = @"ProgressData";
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
ubiquitousContentURL, NSPersistentStoreUbiquitousContentURLKey,
storeUbiquitousContentName, NSPersistentStoreUbiquitousContentNameKey, nil];
// get url for progress db
NSURL *progressUrl = [ubiq URLByAppendingPathComponent:@"Documents/LocalData.nosync/ProgressData.sqlite"];
// create or open core data sql progress database
NSError *error = nil;
progressModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
progressContext = [[NSManagedObjectContext alloc] init];
progressPsc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:progressModel];
[progressContext setPersistentStoreCoordinator:progressPsc];
[progressPsc lock];
[progressPsc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:progressUrl options:options error:&error];
[progressPsc unlock];
由于 射线
答案 0 :(得分:0)
发现了这个问题。看来我必须手动创建'LocalData.nosync'目录。如果它尚不存在,则不会被创建。