Before Task, we already had a little experience of iCloud: our games, SEQ and ON/OFF, use it to sync levels solved by players between their devices. Of course, with Task we had to sync tasks which is a much more complicated problem.
SEQ and ON/OFF sync is based on the Key-value storage provided by the iCloud API which is easy to set up and to use. This kind of storage, however, cannot be used in Task because it doesn't support huge amount of data. There are two other kinds of iCloud storage: Document storage and Core Data storage. Our first move was to try iCloud Core Data storage. It was a mistake: we were not able, as many other developers, to make it work. Our only option left was iCloud Document storage.
And it actually works quite well! So, how do we use it to sync tasks? As for many problems, the simplest solution is often the best: changelogs. It is straightforward to use and, if iCloud gets crazy, users have access to their data anyway.
In Task, tasks are stored in a local database. In order to remain synced, an app has to "send" its changes to iCloud and "get" the new ones from it. So, there are 3 players involved: iCloud, the changelogs and the local database. Also, we can identify two types of change: local to iCloud
("send" to iCloud) and iCloud to local
("get" from iCloud).
To achieve this, each occurrence of the app (i.e. a device with Task signed in to the same iCloud account) is responsible for its own changelog. Every time a change is made, it has to be added to the changelog, this is the local to iCloud
part. The changelogs are stored on iCloud so an occurrence of Task can access to the other changelogs, this is the iCloud to local
part. Simple isn't it? Of course there are some subtleties: for example it is not possible to get the changes from iCloud and apply them to the local database directly, the app has to be ready (the user is not doing something). To do so, the raw changes are first converted/merged into applicable changes (this can be done in background at any time) and, when the app will be ready, it will check if there are some pending changes and, only then, will apply them to the local database.
It was a long journey to integrate iCloud with Task but, on a user's point of view, it was worth it. However, keep in mind that iCloud is not as magical as Apple says, especially for developers. It is hard to set up, so please, be indulgent :)