Iphone iCloud基本URL为空

Iphone iCloud基本URL为空,iphone,ios,ipad,url,icloud,Iphone,Ios,Ipad,Url,Icloud,我有下面的代码,正在尝试访问iCloud目录 (void) reloadFiles{ NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *containerID=@"KSC75JA957.Dcdmc.TinyPix"; NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil]; NSLo

我有下面的代码,正在尝试访问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。

“无法配置集合”表示文档同步以某种方式被禁用

您是否已登录iCloud,是否启用了文档和数据? 如果由于以下两个原因之一而未启用文档同步,
cloudURL
将为
nil


如果
cloudURL
nil
,则不应尝试使用iCloud。

是否确实在设备上启用了iCloud?参考:


您确定已在设备上启用icloud?参考:


您首先需要在开发者门户网站上为您的应用程序启用iCloud支持。

您首先需要在开发者门户网站上为您的应用程序启用iCloud支持。

您要使用cloudURL吗?如果是这样的话,可能NIL标识符与此有关?我曾尝试使用容器标识符而不是“NIL”,但仍然出现相同的错误。所以我想,这不是问题所在。当
cloudURL
nil
时,意味着该设备上不提供iCould服务。您打算使用cloudURL吗?如果是这样的话,可能NIL标识符与此有关?我曾尝试使用容器标识符而不是“NIL”,但仍然出现相同的错误。所以我想,这不是问题所在。当
cloudURL
nil
时,意味着该设备上没有iCould服务。
this is the error that occurs when you haven't enabled iCloud on the device on which you are testing. once i enabled iCloud on the device, the error stopped occurring in my log.

and so now i know what error to check for in order to present the user with a dialog saying "connecting to iCloud won't work until you sign up for iCloud in the system preferences".