The CloudKit Framework is one of the more remarkable developer feature available in iOS SDK solely because of the was with which it allows for the structured storage and retrieval of data on Apple's iCloud database servers.
An Overview of CloudKit:
The CloudKit Framework provides applications with access to the iCloud servers hosted by Apple and provides an easy to use way to store, manage and retrieve data and other asset type(such as large binary files, videos and images in a structured way. This provides a platform for users to store private data and access it from multiple devices, and also for the developer to provide data that is publicly available to all the users of an application.
Each CloudKit enabled application has at least one container on iCloud. The container for an application is represented in the CloudKit Framework by the CKContainer class and it is within these containers that the database resides. Containers may also be shared between multiple applications.
A reference to an application's default container can be obtained via the default property of the CKContainer class:
let container = CKContianer.default
CloudKIt Public Database:
Each cloud container contains a single public database. This is the database into which is stored data that is needed by all users of an application. A map application, for example, might have a set of data about locations and routes that are applicable to all users of the application. This data would be stored within the public database of the application's cloud container.
A reference to the public cloud database for a container can be obtained via the publicCloudDatabase property of container instance.
let publicDatabase = container.publicCloudDatabase