Designing for Core Data in iCloud

Adopting iCloud Core Data storage makes the content in a shoebox-style app (like iPhoto) or a database-style app (like Bento) available on all of a user’s devices. See iCloud Programming Guide for Core Data for a complete implementation strategy.

Core Data Sends Incremental Changes to iCloud

Each instance of your app, on each device attached to an iCloud account, maintains its own local Core Data store file. When data changes locally, Core Data writes change log files to your app’s default ubiquity container.

The change log files, not the store file, are uploaded to iCloud and downloaded to each of a user’s other devices. When a change log arrives from another device attached to the same iCloud account, Core Data updates your app’s local copy of the SQLite database, based on the received change log. iCloud and Core Data ensure that each local database is updated with the same set of changes.

To learn more about using SQLite persistent stores with iCloud, see Using the SQLite Store with iCloud in iCloud Programming Guide for Core Data.

Managed Documents Support iCloud

The UIManagedDocument class is the primary mechanism through which Core Data stores managed documents in iCloud on iOS. The UIManagedDocument class manages the entire Core Data stack for each document in a document-based app. Read Using Document Storage with iCloud in iCloud Programming Guide for Core Data to find out how to use managed documents in your app.

In OS X, Core Data integrates with the document architecture through the NSPersistentDocument class. However, in OS X v10.8, instances of this class do not provide specific support for iCloud.

Design the Launch Sequence for Your iCloud Core Data App

When you adopt iCloud, take special care when designing the launch sequence for your app. The following factors come into play and you must account for them: