简体   繁体   中英

share NSPersistentCloudKitContainer between app and extension

I have an embedded framework that defines my core data container on CloudKit with:

let container = NSPersistentCloudKitContainer(name: containerName, managedObjectModel: objectModel)

This embedded framework is used by the app to insert/read data in this coredata container.

I want to add an (intent) app extension that may act directly on this same coredata container.

How can I access this CloudKit container from the extension? Is there a way to do that? And also how to share the same object model file (.xcdatamodeld) between app and extension?

You need to use App Group , and I can provide you this example for starting point.

Also if you are interested in how to pass data from Siri intent to your app, take a look at this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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