Game Development Reference
In-Depth Information
How to do it…
iCloud allows you to store and retrieve data easily from its secured server. This also
provides an additional facility of sharing saved data among multiple applications. To save
this data, our iCloud app places the data in a special local filesystem called the iCloud con-
tainers. It is also called ubiquity container , and serves as the local representation of the
corresponding iCloud storage. This data is totally separate from the rest of our app data; it
is kept by the operating system.
For some iCloud services, our app does not communicate directly to the iCloud servers, in-
stead, the operating system manages all this uploading and downloading of data for the
devices attached to the iCloud account. However, CloudKit provides the facility to manage
these activities. The following are the steps required for using these services:
1. Configure the access to our app's iCloud containers. It involves requesting entitle-
ments and programmatically initializing these containers.
2. Design the app to handle the responses of iCloud services accordingly, such as
when the user signs out of iCloud and instances of our app on other devices can
edit the data.
3. Read/write using the proper iCloud API.
4. The operating system coordinates the transition of data to and from iCloud when
needed as per the design of the app.
We have briefly discussed the iCloud containers already, so this is the time to implement
the iCloud containers in our app. To implement them, we will open the Capabilities tab of
our Xcode project, which manages the entitlements and containers of our app. When we
enable iCloud in the same tab, then Xcode configures our app to the default iCloud contain-
er whose name is based on the app's bundle ID. This default container is used by most apps
as shown in the following screenshot:
Search WWH ::




Custom Search