Non-Standard Cloudkit Container Access with Swift

I have an iOS 8 app that successfully writes entries to my default Cloudkit container. Now I want to read and process these records in another application under OS X. I installed a new application with iCloud access and with the option โ€œSpecify custom containersโ€. This container of the source application has been successfully found and I have not fixed errors in the capabilities interface.

All my searches tell me that โ€œItโ€™s possible that two applications signed by the same developer have the same container,โ€ but not one of the training documents I can find tells me how to access the data from a custom container. All examples seem to start with "let container = CKContainer.defaultContainer ()". However, I do not want to access records from the default container. I want to create a custom container.

Apple's documentation suggests using the init () structure, but that also puzzled me. This seems like a simple request. Hope someone can give me a simple solution.

+6
source share
1 answer

This is unverified code, but I understand that custom containers allow you to share these containers in multiple applications. In the Features panel, you can choose which of all containers is available in all of your other applications that you want to use in this application. The default container is iCloud.com.MyCompany.MyApp , which should be automatically selected. Now that you have specified which containers you want, you can access them using init()

 let container = CKContainer(identifier: "iCloud.com.MyCompany.OneOfMyApps") 

Basically, an identifier is one of the identifiers listed in the iCloud capabilities panel in custom containers.

+9
source

All Articles