iosicloudcloudkitckcontainer

Can I transfer CloudKit data to a new Container?


I'm making a CloudKit app, and I'm faced with the choice of storing my data in the default container, accessible only by that app, or a custom container that can share data. For now I only need that app to access the data, so I would probably put my data in the default container. However, if eventually I want to access this data from a different app, can I transfer my user data to a custom, shareable container?


Solution

  • No need to transfer your data: the default container can be used from your other apps.

    You can specify the name of your original app's default container in your new app's CloudKit capabilities and then use it to initialise a CKContainer to access it.

    See this SO answer and 'Share Containers Between Apps' and 'Enable iCloud and Select CloudKit' in this Apple Doc for details.