热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

iCloud核心数据IOS8路径不在任何CloudDocs容器中-iCloudCoreDataIOS8PathisoutsideofanyCloudDocsContainer

MyiCloudCoreDataappwasrunninggreatoniOS7andreadytolaunch.WhenItestoniOS8Igetth

My iCloud Core Data app was running great on iOS7 and ready to launch. When I test on iOS 8 I get the following error and can't seem to fix it when trying to upload data to iCloud.

我的iCloud核心数据应用程序在iOS7上运行良好并准备启动。当我在iOS 8上测试时,我收到以下错误,并且在尝试将数据上传到iCloud时似乎无法修复它。

I suspect my problem is related to how I am getting the document directory and changes in the doc directory with iOS8 but I just can't figure this out..

我怀疑我的问题与我如何使用iOS8获取文档目录和doc目录中的更改有关但我无法弄清楚这一点..

014-10-12 15:14:17.862 XXXXXXX [4662:236693] __45-[PFUbiquityFilePresenter processPendingURLs]_block_invoke(439): CoreData: Ubiquity:  Librarian returned a serious error for starting downloads Error Domain=BRCloudDocsErrorDomain Code=6 "The operation couldn’t be completed. (BRCloudDocsErrorDomain error 6 - Path is outside of any CloudDocs container, will never sync)" UserInfo=0x7f8b1a525f60 {NSDescription=Path is outside of any CloudDocs container, will never sync, NSFilePath=/Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt} with userInfo {
    NSDescription = "Path is outside of any CloudDocs container, will never sync";
    NSFilePath = "/Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt";
} for these urls: (
    "file:///Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt"
)

my app delegate extension code where I create my persistent store is as follows. I have a seed database for first time installation.

我的app委托扩展代码,我创建我的持久存储如下。我有第一次安装的种子数据库。

- (NSPersistentStoreCoordinator *)createPersistentStoreCoordinator{
   NSPersistentStoreCoordinator *persistentStoreCoordinator = nil;
   NSManagedObjectModel *managedObjectModel = [self createManagedObjectModel];
   persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]initWithManagedObjectModel:managedObjectModel];
   NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@
   "CoreData.sqlite"];    

   if (![[NSFileManager defaultManager]fileExistsAtPath:[storeURL path]]){
       NSURL *preloadURL=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"SeedDatabase" ofType:@
       "sqlite"]];
       NSError *error=nil;
       if (![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&error]){
           NSLog(@
           "File couldnt save");
       }
   }


   NSUbiquitousKeyValueStore *kvStore=[NSUbiquitousKeyValueStore defaultStore];
   if (![kvStore boolForKey:@"SEEDED_DATA"]){
       NSLog (@
       "In the new database");
       NSURL *seedStoreURL=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"SeedDatabase" ofType:@
       "sqlite"]];
       NSError *seedStoreErrpr;
       NSDictionary *seedStoreOptiOns=@{NSReadOnlyPersistentStoreOption: @YES};
       NSPersistentStore *seedStore=[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:seedStoreURL options:seedStoreOptions error:&seedStoreErrpr];

       NSDictionary *iCloudOptiOns=@{NSPersistentStoreUbiquitousContentNameKey: @"iCloud",
                                       NSMigratePersistentStoresAutomaticallyOption:@YES,
                                       NSInferMappingModelAutomaticallyOption:@YES
       };

       NSOperationQueue *queue=[[NSOperationQueue alloc] init];
       [queue addOperationWithBlock:^{
           NSError *error;
           [persistentStoreCoordinator migratePersistentStore:seedStore toURL:storeURL options:iCloudOptions withType:NSSQLiteStoreType error:&error];
           NSLog(@
           "Persistant store migrated");
           [kvStore setBool:YES forKey:@
           "SEEDED_DATA"];
          // [self checkForDuplicates];
       }];
   }else{
       NSError *error;
       NSDictionary *storeOptiOns=@{NSPersistentStoreUbiquitousContentNameKey: @
          "iCloud"
       };
       if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                        configuration:nil
                                        URL:storeURL
                                        options:storeOptions
                                        error:&error]) {
           NSLog(@
           "Unresolved error %@, %@", error, [error userInfo]);
           abort();
       }
   }

   return persistentStoreCoordinator;
}

- (NSURL *)applicationDocumentsDirectory{
   return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory    inDomains:NSUserDomainMask] lastObject];
}

2 个解决方案

#1


5  

I was able to resolve this error by specifying the iCloud drive directory (Same name as the one on the developer.apple.com interface).

我能够通过指定iCloud驱动器目录(与developer.apple.com界面上的名称相同)来解决此错误。

-(NSURL *)cloudDirectory
{
NSFileManager *fileManager=[NSFileManager defaultManager];
NSString *teamID=@"iCloud";
NSString *bundleID=[[NSBundle mainBundle]bundleIdentifier];
NSString *cloudRoot=[NSString stringWithFormat:@"%@.%@",teamID,bundleID];
NSURL *cloudRootURL=[fileManager URLForUbiquityContainerIdentifier:cloudRoot];
NSLog (@"cloudRootURL=%@",cloudRootURL);
return cloudRootURL;
}

and including it in the icloudOptions Dictionary as a NSPersistentStoreUbiquitousContentURLKey

并将其作为NSPersistentStoreUbiquitousContentURLKey包含在icloudOptions字典中

NSDictionary *storeOptiOns=@{NSPersistentStoreUbiquitousContentNameKey: @"iCloud",
                                   NSPersistentStoreUbiquitousContentURLKey:[self cloudDirectory],
                                   };

I was getting some strange errors so I removed the app from all devices, deleted the iCloud drive file and re ran on an actual device and it worked fine. Not sure if it runs on IOS7 now but since I only specified the NSPersistentStoreUbiquitousContentURLKey I am pretty confident it should be fine.

我收到了一些奇怪的错误,所以我从所有设备中删除了应用程序,删除了iCloud驱动器文件并在实际设备上重新运行,它运行正常。不知道它现在是否在IOS7上运行,但由于我只指定了NSPersistentStoreUbiquitousContentURLKey,我相信它应该没问题。

#2


-1  

I had the same issue during loading some test data. For the load of the data I was deleting all records. To avoid the exception a simple sleep(1) between cleaning and loading was enough.

在加载一些测试数据时我遇到了同样的问题。对于数据的加载,我删除了所有记录。为了避免异常,清洁和装载之间的简单睡眠(1)就足够了。


推荐阅读
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • 怀疑是每次都在新建文件,具体代码如下 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • ALTERTABLE通过更改、添加、除去列和约束,或者通过启用或禁用约束和触发器来更改表的定义。语法ALTERTABLEtable{[ALTERCOLUMNcolu ... [详细]
  • 本文讨论了clone的fork与pthread_create创建线程的不同之处。进程是一个指令执行流及其执行环境,其执行环境是一个系统资源的集合。在调用系统调用fork创建一个进程时,子进程只是完全复制父进程的资源,这样得到的子进程独立于父进程,具有良好的并发性。但是二者之间的通讯需要通过专门的通讯机制,另外通过fork创建子进程系统开销很大。因此,在某些情况下,使用clone或pthread_create创建线程可能更加高效。 ... [详细]
  • 本文介绍了iOS数据库Sqlite的SQL语句分类和常见约束关键字。SQL语句分为DDL、DML和DQL三种类型,其中DDL语句用于定义、删除和修改数据表,关键字包括create、drop和alter。常见约束关键字包括if not exists、if exists、primary key、autoincrement、not null和default。此外,还介绍了常见的数据库数据类型,包括integer、text和real。 ... [详细]
  • 本文讨论了在openwrt-17.01版本中,mt7628设备上初始化启动时eth0的mac地址总是随机生成的问题。每次随机生成的eth0的mac地址都会写到/sys/class/net/eth0/address目录下,而openwrt-17.01原版的SDK会根据随机生成的eth0的mac地址再生成eth0.1、eth0.2等,生成后的mac地址会保存在/etc/config/network下。 ... [详细]
  • 本文介绍了机器学习手册中关于日期和时区操作的重要性以及其在实际应用中的作用。文章以一个故事为背景,描述了学童们面对老先生的教导时的反应,以及上官如在这个过程中的表现。同时,文章也提到了顾慎为对上官如的恨意以及他们之间的矛盾源于早年的结局。最后,文章强调了日期和时区操作在机器学习中的重要性,并指出了其在实际应用中的作用和意义。 ... [详细]
author-avatar
Breerus
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有