所以我正在将我的核心数据迁移到 UIManagedDocument。
在 iPhone 模拟器上调用 openWithCompletionHandler 可以正常工作,但是当我尝试在真实设备上运行我的项目时,它总是返回 NO。我覆盖了handleError,这就是我得到的:
Error Domain=NSCocoaErrorDomain Code=260
"The operation couldn’t be completed. (Cocoa error 260.)"
UserInfo=0x1edafa90 {path=file://localhost/var/mobile/Applications/D57D7EAC-6E92-4CAD-97E7-179010CB6738/Project%20APP.app/DataModel.momd/StoreContent.nosync, NSUnderlyingError=0x1ed8e160
"The operation couldn’t be completed. (Cocoa error 513.)", reason=Unable to restore path to store content}
这就是我所说的:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: PrivateName, NSPersistentStoreUbiquitousContentNameKey, // cloudURL, NSPersistentStoreUbiquitousContentURLKey, [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; [self setPersistentStoreOptions:options]; [self openWithCompletionHandler:^(BOOL success) { if (success) NSLog(@"opened"); else { NSLog(@"Not opened"); } }];