Xcode-“提供的泛在名称已在使用中" -如何找到文件夹 [英] Xcode - "The provided ubiquity name is already in use" - how do I find a folder

查看:77
本文介绍了Xcode-“提供的泛在名称已在使用中" -如何找到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Xcode中收到此消息:

I'm getting this message in Xcode:

    The provided ubiquity name is already in use., 
NSURL=file://localhost/var/mobile/Applications/6C748748-9689-4F40-B8D7-
CDE8CA280FF8/Documents/SharedCoreDataStores/138F8194-DCC7-4D66-859B-
B2C35BDF2984/iCloudStore.sqlite

如何找到此文件(iCloudStore.sqlite)的位置?我已经尝试过〜/Library/Containers和〜/Library/Mobile Documents.

How do I find the location of this file (iCloudStore.sqlite)? I've tried ~/Library/Containers and ~/Library/Mobile Documents.

谢谢

推荐答案

您可以在以下位置找到它

you can find it at

NSURL *DocumentsURL = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject;

NSURL *tempURL = DocumentsURL;
tempURL = [tempURL URLByAppendingPathComponent:@"sharedCoreDataStores"];
tempURL = [tempURL URLByAppendingPathComponent:@"138F8194-DCC7-4D66-859B-B2C35BDF2984"];
tempURL = [tempURL URLByAppendingPathComponent:@"iCloudStore.sqlite"];
NSURL *iCloudStoreURL = tempURL;

iCloudStoreURL是您想要的. 您可以使用iCloud演示代码从核心数据创建此存储.对吧?

iCloudStoreURL is what you want. You create this store from a core data with iCloud demo code. Right?

您已在[coordinator addPersistentStore]函数中传递了此商店URL.

you have passed this store URL in [coordinator addPersistentStore] functions.

将iCloud与Core Data结合使用时,您应该注意两个位置和一个名称:

there are two location and one name you should notice when using iCloud with Core Data:

iCloud存储真实文件,它将所有数据存储在本地文件夹中.每个设备都有一个存储文件.它将自动从iCloud传输数据.

the iCloud store real file, it store all the data in local folder. Every device have a store file. It will automatic transfer data from iCloud.

添加iCloud存储时,将此存储URL传递给[coordinator addPersistentStore]函数.

When adding a iCloud store, you pass this store url to [coordinator addPersistentStore] function.

然后商店文件将位于该URL.

Then the store file will locate at that URL.

它应该在本地文件夹中,例如documentsDirectory中的子目录

It should in an local folder, like a subdirectory in documentsDirectory

for example: 
[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject URLByAppendingComponent:@"iCloudStore"];

或其他目录.我的选择是

or some other directory. My choice is

[[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask].lastObject URLByAppendingComponent:@"iCloudStore"];

2. iCloud CoreData内容URL

此URL在iCloud容器(或名为普遍存在的容器"的代码)中. 它仅用于记录核心数据内容的更改.

2.iCloud CoreData Content URL

This URL is in a iCloud container (or code named "ubiquity container"). It is only used for recording the change for the core data content.

想一想就可以了. [NSFileManager URLForUbiquityContainer:nil]是该云的位置.

Think it in a cloud. [NSFileManager URLForUbiquityContainer:nil] is the location of that cloud.

iCloud CoreData Content URL用于此无处不在容器上的所有iCloud核心数据数据库传输日志. (不同应用程序上的不同核心数据数据库可能位于同一个普遍存在的容器中,并将所有日志存储在此contentURL中.)

iCloud CoreData Content URL is used for all the iCloud core data databases transfer logs on this ubiquity container. (Different core data databases on different apps maybe in the same ubiquity container and store the logs all in this contentURL.)

设置用于添加iCloud Store的选项时,您将传递此URL:

You pass this URL when you set the options for adding iCloud Store:

 NSDictionary *cloudOptions =
 @{  NSMigratePersistentStoresAutomaticallyOption:@(YES),
 NSInferMappingModelAutomaticallyOption      :@(YES),
 NSPersistentStoreUbiquitousContentNameKey   :self.iCloudCoreDataContentName,
 NSPersistentStoreUbiquitousContentURLKey    :self.iCloudCoreDataContentURL}

此URL应该是iCloud容器的子目录,例如[[NSFileManager URLForUbiquityContainer:nil] URLByAppendingComponent:@"CoreDataLogs"].

this URL should be a subdirectory of the iCloud container, like [[NSFileManager URLForUbiquityContainer:nil] URLByAppendingComponent:@"CoreDataLogs"].

此属性在选项中是可选的.如果您省略它,则iCloud CoreData内容URL将为[NSFileManager URLForUbiquityContainer:nil].

this property is optional in options. If you omit it, the iCloud CoreData Content URL will be [NSFileManager URLForUbiquityContainer:nil].

指定核心数据数据库的唯一名称. 每个iCloud商店都需要它.不同的iCloud商店应使用不同的名称.

Specify an unique name for a core data database. It is required for every iCloud store. Different iCloud stores should have different names.

设置用于添加iCloud Store的选项时,您将使用此名称:

You pass this name when you set the options for adding iCloud Store:

 NSDictionary *cloudOptions =
 @{  NSMigratePersistentStoresAutomaticallyOption:@(YES),
 NSInferMappingModelAutomaticallyOption      :@(YES),
 NSPersistentStoreUbiquitousContentNameKey   :self.iCloudCoreDataContentName,
 NSPersistentStoreUbiquitousContentURLKey    :self.iCloudCoreDataContentURL}

这篇关于Xcode-“提供的泛在名称已在使用中" -如何找到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆