我有一个数据库应用程序。单一实体。我刚刚升级它以启用iCloud同步。这是我的app委托中的PSC:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (persistentStoreCoordinator__ != nil)
{
return persistentStoreCoordinator__;
}
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Logbook.sqlite"];
NSURL *storeURL = [NSURL fileURLWithPath:storePath];
persistentStoreCoordinator__ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
NSPersistentStoreCoordinator* psc = persistentStoreCoordinator__;
if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5.0")) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"We're iniOS 5!");
// Migrate datamodel
NSDictionary *options = nil;
// this needs to match the entitlements and provisioning profile
NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:@"XXXXXXXXXX.com.burgul.Logbook"];
NSString* coreDataCloudContent = [[cloudURL path] stringByAppendingPathComponent:@"data"];
if ([coreDataCloudContent length] != 0) {
// iCloud is available
NSLog(@"...and iCloud is live!");
cloudURL = [NSURL fileURLWithPath:coreDataCloudContent];
options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
@"Logbook.store", NSPersistentStoreUbiquitousContentNameKey,
cloudURL, NSPersistentStoreUbiquitousContentURLKey,
nil];
} else {
// iCloud is not available
NSLog(@"...but iCloud unavailable!");
options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
nil];
}
NSError *error = nil;
[psc lock];
if (![psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
[psc unlock];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"asynchronously added persistent store!");
[[NSNotificationCenter defaultCenter] postNotificationName:@"RefetchAllDatabaseData" object:self userInfo:nil];
});
});
} else {
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
nil];
NSError *error = nil;
if (![psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
return persistentStoreCoordinator__;
}
我一直都会遇到此错误,但iCloud同步似乎可以在iPhone和iPad之间运行。我应该担心吗?它为什么会出现?:
Feb 28 22:23:40 unknown Logbook[2191] <Warning>: We're iniOS 5!
Feb 28 22:23:41 unknown Logbook[2191] <Warning>: Root view loading...
Feb 28 22:23:41 unknown Logbook[2191] <Warning>: ...and iCloud is live!
Feb 28 22:23:41 unknown sandboxd[2192] <Notice>: Logbook(2191) deny file-write-data /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~burgul~Logbook
Feb 28 22:23:42 unknown Logbook[2191] <Warning>: -[PFUbiquityTransactionLog loadComparisonMetadataWithError:](220): CoreData: Ubiquity: Error encountered while trying to load the comparison metadata for transaction log: <PFUbiquityTransactionLog: 0x1fc020>
transactionLogLocation: <PFUbiquityLocation: 0x1fb3a0>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~burgul~Logbook/data/mobile.7B7D20A-AD93-5631-9E0D-61B5E5AE1DB0/Logbook.store/1DGRB5~3_aHWVwlP9v9teBUHYhFYHcmj6kWm8HjF~8=/5837F007-B39E-42C2-A3D1-F69998C2F251.1.cdt
transactionNumber: (null)
Error: Error Domain=NSCocoaErrorDomain Code=134301 "The operation couldn’t be completed. (Cocoa error 134301.)" UserInfo=0x172880 {reason=Error during property list parsing during import or opening of log file at location: <PFUbiquityLocation: 0x1fb7d0>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~burgul~Logbook/data/mobile.7B7D20A-AD93-5631-9E0D-61B5E5E1DB0/tempLogs.nosync/Logbook.store/1DGRB5~3_aHWVwlP9vteBUHYhFYUHmj6kWm8HjF~8=/5837F007-B39E-42C2-A3D1-F6998C2F251.1.cdt, error: Error Domain=NSCocoaErrorDomain Code=134301 "The operation couldn’t be completed. (Cocoa error 134301.)" UserInfo=0x185e80 {missingFile=/private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~burgul~Logbook/data/mobile.7B7D20A-AD93-5631-9E0D-61B5E5AE1DB0/tempLogs.nosync/Logbook.store/1DGRB5~3_aHWVwlP9v9teBUHYhFYUHmj6kWm8HjF~8=/5837F07-B39E-42C2-A3D1-F69998C2F251.1.cdt}}
Feb 28 22:23:42 unknown Logbook[2191] <Warning>: -[PFUbiquityTransactionLog loadComparisonMetadataWithError:](220): CoreData: Ubiquity: Error encountered while trying to load the comparison metadata for transaction log: <PFUbiquityTransactionLog: 0x171780>
答案 0 :(得分:1)
你看到这篇文章了吗?你的问题似乎很相似。 @ Axel的解释似乎有效。
答案 1 :(得分:1)
尽管出现上述错误,我仍然将我的应用提交到应用商店。它被接受并且已经存在了2周。一切似乎工作正常,没有不良反馈。因此决定放松并忘记它!