To add a CKRecord in a private CKRecordZone you need to make sure the zone exists already.
But does it mean that every time I need to insert a record I need to fetch all the zones and find if my zone exists using fetchAllRecordZonesWithCompletionHandler
? It wouldn't be very efficient.
What is the best strategy to adopt ?
Most of the examples I have seen show how to create a zone and add a record into it. But you are not going to create the zone every time, and you can't just assume it exists...
Code below will fail if the zone has not been created already
let customZone = CKRecordZone(zoneName: self.zoneName!)
// Create a CKRecord
let lessonRecord = CKRecord(recordType: self.recordType, zoneID: customZone.zoneID)
Thanks for your help.