Chapter 21. Cloud
One of the really great frameworks in the iOS SDK is CloudKit. Using this framework, you can store public and private information on the cloud with ease. One of the key concepts in CloudKit is containers, which are virtual boxes that encapsulate public and private databases.
Before I go into more details about all this jargon, let’s imagine a
simple scenario. Your app is running on an iOS device and the owner of
that device has an iCloud account already set up for herself. Every app
that runs on that device has its own CloudKit container and multiple apps
can share containers if they are set up in a specific way. Your default
container is your app’s own container, but you can find a container for
another app if you know its unique identifier in the cloud. Containers are
represented by the
CKContainer class in
Every container (and therefore every app that uses a container) has two databases: one public and the other private. When you use the private database and store information there, the information is saved in the user’s iCloud account and is private to her on that device for your app. If you use the public database, the user doesn’t need an iCloud account to be able to read that information. So all users of your app can use information from the public database.
Information that is stored in the public database for your app counts against your iCloud storage quota, so be very careful about tracking its size. The information stored ...