title: How to sync records between Core Data and CloudKit efficiently
body: <p>I'm currently learning how to use CloudKit Framework and lack of documentation or examples showing how to sync Core Data and CloudKit.</p>
  
  <p>I have watched all WWDC videos (2014, 2015, 2016) Dedicated to CloudKit, but none of them telling us how to implement syncing with Core Data. I can't find any fresh examples, tutorial or books, showing how to implement this syncing. </p>
  
  <p>I know that it is effective to use Operations API by CloudKit (not Convenience API) and to Subscribe to changes as it said in the new WWDC 2016 videos, dedicated to CloudKit, but mapping with CoreData is a real problem.</p>
  
  <p>For example, let's say I would like to create an app similar to Notes app. while offline, user can create his notes and work with them saving them to his core data database. When the device going online the app checks what changed on the server and saves newly created records to server (CloudKit). </p>
  
  <p>When the app starts, it also fetches for changes from the CloudKit and if there are changes , it updates local cache (Core Data) with the new changes. </p>
  
  <p>I would appreciate to have a common pattern of syncing. Where to place syncing with Core Data methods and how they should look like?</p>
  
  <p>Would appreciate any information or help about this. </p>
  
  <p>I'm using Swift 3, Xcode 8 , iOS 10.</p>