加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – URLForUbiquityContainerIdentifier总是返回nil

发布时间:2020-12-14 17:43:26 所属栏目:百科 来源:网络整理
导读:模拟器在iOS8.1中,我正在使用 Xcode 6.1.1. 我尝试过几个不同来源的解决方案: URLForUbiquityContainerIdentifier alway return nil URLForUbiquityContainerIdentifier returns nil even if configured correctly https://devforums.apple.com/thread/2295
模拟器在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,那么除了在真实设备上进行测试之外,没有其他解决方法.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读