微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – URLForUbiquityContainerIdentifier总是返回nil

模拟器在iOS8.1中,我正在使用 Xcode 6.1.1.

我尝试过几个不同来源的解决方案:

> URLForUbiquityContainerIdentifier alway return nil
> URLForUbiquityContainerIdentifier returns nil even if configured correctly
> https://devforums.apple.com/thread/229509

似乎没有任何工作.我的设置:

权利和能力:

码:

dispatch_async(dispatch_get_global_queue (disPATCH_QUEUE_PRIORITY_DEFAULT,0),^(void) {
    NSURL *myContainer = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];

    // unarchive journal object from iCloud
    if (myContainer != nil) {
        Nsstring *filePath = [Nsstring stringWithFormat:@"%@/%@",myContainer.path,ARCHIVE_FILE_NAME];
        self.journal = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];

        // initialize journal from local storage if there's no iCloud archive
        if (self.journal == nil)
            [self initJournalFromLocalStorage];
        else
            [self.journal validateUserDefines];

        self.journal.cloudURL = myContainer;

        dispatch_async (dispatch_get_main_queue (),^(void) {
            // On the main thread,update UI and state as appropriate
        });
    }
});

我的Apple ID已启用iCloud进行开发和分发;我尝试过创建和下载新的配置文件.

我还尝试在.entitlements中将iCloud.$(CFBundleIdentifier)更改为$(TeamIdentifierPrefix)$(CFBundleIdentifier).

无论我做什么,URLForUbiquityContainerIdentifier总是返回nil.任何帮助表示赞赏!

解决方法

您是否在模拟器上启用了iCloud Drive?

根据我自己的测试,如果使用iOS 8.1模拟器禁用iCloud Drive,则URLForUbiquityContainerIdentifier始终返回nil.但是,如果您在具有相同设置的设备上进行测试,则会返回有效值.同样,如果启用了iCloud Drive,则模拟器将返回正确的值.如果您不想启用iCloud Drive,那么除了在真实设备上进行测试之外,没有其他解决方法.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐