【问题标题】:how to sync core data icloud with ios and macOs app如何将核心数据 icloud 与 ios 和 macOS 应用程序同步
【发布时间】:2012-01-21 04:41:10
【问题描述】:

我正在开发一个将 CoreData 与 iCloud 结合使用的 iPad 应用程序。效果很好! 我可以使用与我的团队 ID 和 iCloud 容器匹配的文件夹打开 ~/Library/Mobile Documents"。 我也在制作一个需要访问 iCloud 的 macOS 应用程序。在 macOS 应用程序中,我添加了 iOS 应用程序容器 ID。所以我有两个容器 ID:ca.company.MacContainerID 和 ca.company.IPadContainerID,适用于 iPad 应用程序。

当我在 MacOS 应用程序中执行以下代码时,URLForUbiquityContainerIdentifier: 返回 nil。

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *containerID =  @"A1B2C3E4F5.ca.company.IPadContainerID";
NSURL *url = [fileManager URLForUbiquityContainerIdentifier:containerID];    
url is nil

我不知道如何使用 iPad 应用程序内部的核心数据访问 iCloud。 你有什么想法吗?

【问题讨论】:

    标签: core-data sync icloud


    【解决方案1】:

    一定是你的containerID有问题。您是否仔细检查了 ID 字符串?

    【讨论】:

      【解决方案2】:

      我找到了解决方案!我正在使用 iOS 配置文件构建 Mac 应用程序。所以我放了一个Mac配置,它可以工作; URLForUbiquityContainerIdentifier 返回一个非空值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-30
        • 2016-07-23
        • 1970-01-01
        • 2014-03-01
        • 2017-03-23
        • 2014-03-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多