简体   繁体   English

iOS中的应用程序组和iCloud

[英]App Groups and iCloud in iOS

I am familiar with iCloud syncing, but I am new to app groups. 我熟悉iCloud同步,但我是应用程序组的新手。 There may be a simple answer to this question, but I haven't found it yet. 这个问题可能有一个简单的答案,但我还没有找到。 Basically, I have an app in which I have iCloud integration, and now I want to try to add a today extension. 基本上,我有一个应用程序,我有iCloud集成,现在我想尝试添加今天的扩展。 I am currently using Core Data as a backend and would like to continue to do so. 我目前正在使用Core Data作为后端,并希望继续这样做。 However, from what I have read, I need to move my data store to a shared location by defining an "App Group". 但是,根据我的阅读,我需要通过定义“应用程序组”将我的数据存储移动到共享位置。 ( http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios-8 and Accessing Core Data SQL Database in iOS 8 Extension (Sharing Data Between App and Widget Extension) ) I haven't been able to find out if this location is synced using iCloud or not. http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios-8iOS 8扩展中的访问核心数据SQL数据库(共享)应用程序和窗口小部件扩展之间的数据) )我无法确定是否使用iCloud同步此位置。 Or, because I"m using iCloud, do I need an App Group at all? I appreciate any and all help/suggestions. 或者,因为我使用iCloud,我是否需要一个应用程序组?我感谢任何和所有的帮助/建议。

If you're already using iCloud, you don't need to use app groups, because your extension can access the same iCloud container as your app does. 如果您已经在使用iCloud,则无需使用应用程序组,因为您的扩展程序可以访问与您的应用程序相同的iCloud容器。 As long as your entitlements and provisioning are configured correctly, you can literally just use the same Core Data stack setup in the extension as in the app. 只要您的权利和配置配置正确,您就可以在扩展中使用与应用程序中相同的Core Data堆栈设置。

Apple's Lister demo project does this, but there's nothing special about it. Apple的Lister演示项目就是这样做的,但没有什么特别之处。 Just use iCloud as usual. 像往常一样使用iCloud。

App groups are usually necessary to share data between apps and extensions. 应用程序组通常需要在应用程序和扩展程序之间共享数据。 But a big exception is when the data is already stored external to the app-- as with iCloud. 但是一个很大的例外是当数据已经存储在应用程序外部时 - 就像iCloud一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM