我正在我的应用程序中使用coredata和icloud。当我在iCloud上创建UIManagedDocument并在iPhone 5以外的设备上调试该应用程序时,它运行良好。但当在iPhone上调试时,它会给出如下错误:
Jun 26 15:49:49 Kumar iPhone库管理员[12461]:无法下载file://localhost/private/var/mobile/Library/Mobile%20Documents/3JPA4W258L~com~leaf~Journal/COREDATABASE/(0x8000000000000000):操作无法完成。(UBErrorDomain错误0。)��6月26日15:49:58 Kumar iPhone库管理员和[12461]:无法下载file://localhost/private/var/mobile/Library/Mobile%20Documents/3JPA4W258Lh~com~leaf~Journal/Logs/(0x8000000000000000):操作无法完成。(UBErrorDomain错误0。)��6月26日15:49:58 Kumar iPhone Journal〔12554〕:-PFUbiquityImportScanOperation main:核心数据:Ubiquity:无法获取根路径(0)的子路径:/private/var/mobile/Library/mobile Documents/3JPA4W258L~com~leaf~Journal/Logs错误:(null)userInfo:(null)��6月26日15:49:58 Kumar iPhone Journal[1254]:-NPersistentStoreCoordinator addPersistentSStoreWithType:配置:URL:选项:错误::CoreData:普遍性:设置普遍性集成时出错:(null)
代码如下:
-(void)saveManagegDocument {
if(iCloud) {
NSError * error = nil;
[coordinator coordinateWritingItemAtURL:managedDoc.fileURL options:NSFileCoordinatorWritingForDeleting error:&error byAccessor:^(NSURL *newURL) {
NSError * delError = nil;
[[NSFileManager defaultManager] removeItemAtURL:newURL error:&delError];
//if(delError)
//NSLog(@"Error deleting data file .... , reason : %@",delError.localizedDescription);
}];
NSError * logerror = nil;
[coordinator coordinateWritingItemAtURL:[managedDoc.persistentStoreOptions valueForKey:NSPersistentStoreUbiquitousContentURLKey] options:NSFileCoordinatorWritingForDeleting error:&logerror byAccessor:^(NSURL *newURL) {
NSError * delError = nil;
[[NSFileManager defaultManager] removeItemAtURL:newURL error:&delError];
//if(delError)
//NSLog(@"Error deleting transaction file .... , reason : %@",delError.localizedDescription);
}];
}
[managedDoc saveToURL:managedDoc.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
if (success) {
[managedDoc closeWithCompletionHandler:^(BOOL success) {
[managedDoc openWithCompletionHandler:^(BOOL success) {
[self performSelectorOnMainThread:@selector(documentReady) withObject:nil waitUntilDone:NO];
}];
}];
} else {
[[[UIAlertView alloc] initWithTitle:@"Could not save or open core data database." message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil] show];
// [self showMessage:@"Could not save or open core data database "];
//NSLog(@"Could not save or open core data database ");
}
}];
}
那么,如果你有,请写下答案?
谢谢。
这些都是内部iCloud+核心数据错误。他们并不意味着你做错了什么,也没有什么可以改变的,让它更好地发挥作用。有时iCloud只是这样做,有时只在一台设备上,有时随机在不同的设备上。你唯一的选择就是以后再试一次,希望能有更好的结果。
我知道这不是任何人想要的答案,但现在核心数据和iCloud就是这样。文件错误,或者尝试iOS 7,看看它是否更好。