HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了什么原因导致iOS iCloud错误:错误域= BRCloudDocsErrorDomain代码= 12“操作无法完成.”延迟后重试:60大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
iPhone / iOS应用程序正在使用COreData sqlite(NSsqliteStoreTypE)iCloud iOs.当应用程序第一次安装(或通过 xcode删除和重新安装后)开始,并且iCloud中的先前的应用程序数据从先前安装或同一帐户中的其他设备发生,则会出现以下错误,然后是60秒的重试延迟,然后成功迁移到iCloud.结果是应用程序升级时,应用程序的用户认为他们的数据丢失.然而,在60秒的延迟之后,数据被恢复.错误和一些代码如下.

什么原因导致这个错误在哪里可以进一步了解这个错误

这里是一个代码段和更详细的日志来提供更多的上下文.

从应用程序委托:

- (void)applicationDidFinishLaunching:(UIApplication *)application { 

            ... standard iCloud and app setup ...

            NsmanagedObjectContext *context = [self managedObjectContext];

            ...

            ... query the db ...
        }

        /**
         Returns the managed object context for the application.
         If the context doesn't already exist,it is created and bound to the persistent store coordinator for the application.
         */
        - (NsmanagedObjectContext *) managedObjectContext {

            if (managedObjectContext != nil) {
                return managedObjectContext;
            }

            NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
            if (coordinator != nil) {
                managedObjectContext = [[NsmanagedObjectContext alloc] init];
                [managedObjectContext setPersistentStoreCoordinator: coordinator];
            }
            managedObjectContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy;  
            return managedObjectContext;
        }

        ...

        /**
         Returns the managed object model for the application.
         If the model doesn't already exist,it is created by merging all of the models found in the application bundle.
         */
        - (NsmanagedObjectModel *)managedObjectModel {

            if (managedObjectModel != nil) {
                return managedObjectModel;
            }
            managedObjectModel = [[NsmanagedObjectModel mergedModelFromBundles:nil] retain];    
            return managedObjectModel;
        }

        ...

        /**
         Returns the persistent store coordinator for the application.
         If the coordinator doesn't already exist,it is created and the application's store added to it.
         */
        - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {

            if (persistentStoreCoordinator != nil) {
                return persistentStoreCoordinator;
            }




            NSURL *storeUrl = [NSURL fileURLWithPath: [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) lastObject] StringByAppendingPathComponent: @"myapp.sqlite"]];

            NSLog(@"App Store URL : %@",storeUrl);

            NSError *error = nil;
            persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];


            NSDictionary *storeOptions;
            storeOptions = @{
                             NSMigratePersistentStoresAutomaticallyOption : @YES,NSInferMappingModelAutomaticallyOption : @YES,NSPersistentStoreUbiquitousContentNameKey: @"AppCloudStore"
                             };
            #ifdef FREE
            storeOptions = @{
                             NSMigratePersistentStoresAutomaticallyOption : @YES,NSPersistentStoreUbiquitousContentNameKey: @"FreeAppCloudStore"
                             };
            #endif

            // Register for Notifications
            NsnotificationCenter *notificationCenter = [NsnotificationCenter defaultCenter];

            [notificationCenter addObserver:self
                                   SELEctor:@SELEctor(storesDidChange:)
                                       name:NSPersistentStoreCoordinatorStoresDidChangeNotification
                                     object:self.persistentStoreCoordinator];

            [notificationCenter addObserver:self
                                   SELEctor:@SELEctor(persistentStoreDidImportUbiquitousContentChanges:)
                                       name:NSPersistentStoreDidImportUbiquitousContentChangesnotification
                                     object:self.persistentStoreCoordinator];

            [notificationCenter addObserverForName:NSPersistentStoreCoordinatorStoresWillChangeNotification
             object:self.persistentStoreCoordinator
             queue:[NSOperationQueue mainQueue]
             usingBlock:^(Nsnotification *notE) {
                 NSLog(@"Stores Will Change...");

                     if ([self.managedObjectContext hasChanges]) {
                         NSError *saveError;
                         if (![self.managedObjectContext save:&saveError]) {
                             NSLog(@"Save error: %@",saveError);
                         }
                     } else {
                         // drop any managed object references
                         [self.managedObjectContext reset];
                     }

             }];


            NSPersistentStore *store = [persistentStoreCoordinator addPersistentStoreWithType:NSsqliteStoreType configuration:nil URL:storeUrl  options:storeOptions error:&error];

            if (store == nil || error != nil) {
                NSLog(@"Error: %@,%@",error,[error userInfo]);
                abort();
            }


            NSURL *finaliCloudURL = [store URL];
            NSLog(@"Created persistent store okay.  Final iCloud URL is: %@",finaliCloudURL);

            return persistentStoreCoordinator;
        }

    ...

    - (void)persistentStoreDidImportUbiquitousContentChanges:(Nsnotification *)notification {

        NSLog(@"persistentStoreDidImportUbiquitousContentChanges: Called.  Content has changed via Core Data iCloud: *******************************************");

            // Received and merge updates from iCloud
            [self.managedObjectContext mergeChangesFromContextDidSaveNotification:notification];
            [self notifyAndrefreshAllDataDueToCloudEvent];
    }

    ...

    - (void)storesDidChange:(Nsnotification *)notification {

        // Tell me: why did my stores changes?
        NS@R_696_10793@er *transitionType = [notification.userInfo objectForKey:NSPersistentStoreUbiquitousTransitionTypeKey];
        int theCause = [transitiontype intValue];

        NSLog(@"storesDidChange: NSPersistentStoreCoordinatorStoresDidChange Notification = %@",notification);

        switch (theCausE) {
            case NSPersistentStoreUbiquitousTransitionTypeAccountAdded: {
                NSLog(@"storesDidChange: Account Added");
                // account was added
            }
                break;
            case NSPersistentStoreUbiquitousTransitionTypeAccountRemoved: {
                NSLog(@"storesDidChange: Account Removed");
                // account was removed
            }
                break;
            case NSPersistentStoreUbiquitousTransitionTypeContentRemoved: {
                NSLog(@"storesDidChange: Content Removed");
                // content was removed
            }
                break;
            case NSPersistentStoreUbiquitousTransitionTypeInitialImportCompleted: {
                NSLog(@"storesDidChange: Initial Import:");
                // initial import
            }
                break;

            default:
                break;

        }

    ... 

        [[NsnotificationCenter defaultCenter]
         postNotificationName:@"*****DidChangeByPersistentStoreChangesnotification"
         object:self];

        [[NsnotificationCenter defaultCenter]
         postNotificationName:@"*****DidChangeByPersistentStoreChangesnotification"
         object:self];

        [[NsnotificationCenter defaultCenter]
         postNotificationName:@"*****DidChangeByPersistentStoreChangesnotification"
         object:self];

    }

更详细的日志:

2015-05-12 10:22:23.367 [4972:2014228] storesDidChange: NSPersistentStoreCoordinatorStoresDidChange Notification = NSConcreteNotification 0x17005f470 {name = NSPersistentStoreCoordinatorStoresDidChangeNotification; object = <NSPersistentStoreCoordinator: 0x170072100>; userInfo = {
    added =     (
        "<NSsqlCore: 0x12dd100b0> (URL: file:///var/mobile/Containers/Data/Application/****/Documents/CoreDataUbiquitySupport/mobile~****-7B78C4F2FDB2/FreeAppCloudStore/2***/store/app.sqlitE)"
    );
}}
2015-05-12 10:22:23.409 [4972:2014228] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808): CoreData: Ubiquity:  mobile~****:FreeAppCloudStore
Using local storage: 1
2015-05-12 10:22:23.410 [4972:2014228] Created persistent store okay.  Final iCloud URL is: file:///var/mobile/Containers/Data/Application/****/store/app.sqlite
2015-05-12 10:22:23.477 [4972:2014228] AppTableViewController:viewWillAppear: enter
2015-05-12 10:22:23.478 [4972:2014228] getSharedAdBAnnerView: enter
2015-05-12 10:22:23.518 [4972:2014228] queryDidupdate: MSMetadataQuery Notification: - NSMetadataQueryDidFinishGatheringNotification
2015-05-12 10:22:23.519 [4972:2014228] queryDidupdate: NSMetadataQuery returned 25 results
2015-05-12 10:22:23.524 [4972:2014228] setProcessTimer: 15.000000
2015-05-12 10:22:23.531 [4972:2014228] TableViewController:viewDidAppear: enter
2015-05-12 10:22:23.531 [4972:2014228] TableViewController:loadData (or reload): enter
2015-05-12 10:22:23.582 [4972:2014294] CoreData: iCloud: Error: initial sync notification returned an error (Error Domain=BRCloudDocsErrorDomain Code=12 "The operation Couldn't be completed. (BRCloudDocsErrorDomain error 12.)")
2015-05-12 10:22:23.594 [4972:2014294] -[PFUbiquitySetupAssistant finishSetupWithRetry:](826): CoreData: Ubiquity:  <PFUbiquitySetupAssistant: 0x12de18940>: retrying after delay: 60
Error Domain=BRCloudDocsErrorDomain Code=12 "The operation Couldn't be completed. (BRCloudDocsErrorDomain error 12.)"
2015-05-12 10:22:23.854 [4972:2014228] didFailToReceiveAdWithError
2015-05-12 10:22:55.150 [4972:2014228] bAnnerViewDidLoadAd
2015-05-12 10:23:24.178 [4972:2014228] queryDidupdate: MSMetadataQuery Notification: - NSMetadataQueryDidupdateNotification
2015-05-12 10:23:24.178 [4972:2014228] queryDidupdate: NSMetadataQuery returned 25 results
2015-05-12 10:23:25.039 [4972:2014228] Stores Will Change...
2015-05-12 10:23:25.101 [4972:2014228] storesDidChange: NSPersistentStoreCoordinatorStoresDidChange Notification = NSConcreteNotification 0x170254940 {name = NSPersistentStoreCoordinatorStoresDidChangeNotification; object = <NSPersistentStoreCoordinator: 0x170072100>; userInfo = {
    NSPersistentStoreUbiquitousTransitionTypeKey = 4;
    added =     (
        "<NSsqlCore: 0x12dd100b0> (URL: file:///var/mobile/Containers/Data/Application/****/FreeAppCloudStore/20EF5D1C-4748-4AB2-BCE1-91B228437D77/store/app.sqlitE)"
    );
    removed =     (
        "<NSsqlCore: 0x12dd100b0> (URL: file:///var/mobile/Containers/Data/Application/*****/store/app.sqlitE)"
    );
}}
2015-05-12 10:23:25.101 [4972:2014646] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808): CoreData: Ubiquity:  mobile~*****FreeAppCloudStore
Using local storage: 0

解决方法

我希望我的答案可以为那些遇到这个错误的人节省很多时间.

当应用程序的删除和安装之间的时间小于一定间隔时,会发生错误.我不知道是否和我一样,我的是15秒.

愚蠢的错误,浪费了几个小时.

大佬总结

以上是大佬教程为你收集整理的什么原因导致iOS iCloud错误:错误域= BRCloudDocsErrorDomain代码= 12“操作无法完成.”延迟后重试:60全部内容,希望文章能够帮你解决什么原因导致iOS iCloud错误:错误域= BRCloudDocsErrorDomain代码= 12“操作无法完成.”延迟后重试:60所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。