0

我有一个数据库应用程序。单一实体。我刚刚升级它以启用 iCloud 同步。这是我的应用程序委托中的 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>
4

2 回答 2

1

尽管出现上述错误,我还是将我的应用程序提交到了应用商店。它被接受并已上线 2 周。一切似乎都运行良好,没有不良反馈。所以决定冷静下来,忘记它!

于 2012-03-10T09:40:38.290 回答
1

你看到这篇文章了吗?你的问题似乎相似。@Axel 的解释似乎是有效的。

iCloud 同步 Ubiquity 错误

于 2012-03-07T12:44:05.383 回答