我有以下代码,正在尝试访问 iCloud 目录。
(void) reloadFiles{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *containerID=@"KSC75JA957.Dcdmc.TinyPix";
NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];
NSLog(@"got cloudURL %@", cloudURL);
self.query = [[NSMetadataQuery alloc] init];
query.predicate = [NSPredicate predicateWithFormat:@"%K like '*.tinypix'", NSMetadataItemFSNameKey];
query.searchScopes = [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope];
[query startQuery];
}
但是,当我运行我的应用程序时,我无法获取云 URL。并且出现以下错误。
got cloudURL (null)
item update error: 0, Error
Domain=LibrarianErrorDomain Code=10 "The operation couldn’t be completed.
(LibrarianErrorDomain error 10 - Unable to configure the collection.)"
UserInfo=0xce65470 {NSDescription=Unable to configure the collection.}
最佳答案
“无法配置集合”意味着文档同步以某种方式被禁用。
您是否已登录 iCloud 并启用了文档和数据?
如果由于这两个原因之一未启用文档同步,cloudURL
将为 nil
。
如果 cloudURL
为 nil
,您不应尝试使用 iCloud。
关于iphone - iCloud 基本 URL 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11207213/