Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudKit CKRecordZone

I have been fiddling with CloudKit for some time now, but I can't find a real-life example for how to use CKRecordZone. I understand their capabilities (namely, grouping records, especially for subscriptions), but does someone have a real experience of having used them, and to map which concept ?

Thanks

like image 339
Frédéric Adda Avatar asked Apr 25 '15 03:04

Frédéric Adda


2 Answers

The Apple News app uses two zones in the private database for the user's information: ReadingList and ReadingHistory. ReadingList stores news article IDs that have been bookmarked; ReadingHistory stores news article IDs that have been read. By separating the article IDs into two different zones it allows them to be efficiently synced. For example, if an article is only read on a device (and not bookmarked), then the other device receives a notification that the ReadingHistory zone has changed, then it only has to sync that zone rather than both. For more info, you can read my full write up on the News app's syncing behavior here.

like image 185
malhal Avatar answered Sep 23 '22 04:09

malhal


CloudKit record zones give you three main benefits:

  1. It allows you to do atomic operations (either all or none of the changes will get applied)
  2. It gives you sync capabilities, so you can fetch record changes from a previous point in time (with a change token) as opposed to having to download the full list of records every time you talk with the server.
  3. It's useful for logically grouping records that belong together.
like image 28
karbonator Avatar answered Sep 21 '22 04:09

karbonator