both of which are kept in sync with CloudKit.
How to determine from which array to fetch data for upload at nextRecordZoneChangeBatch?
func nextRecordZoneChangeBatch(_ context: CKSyncEngine.SendChangesContext, syncEngine: CKSyncEngine) async -> CKSyncEngine.RecordZoneChangeBatch? {
Logger.database.info("Returning next record change batch for context: \(context)")
let scope = context.options.scope
let changes = syncEngine.state.pendingRecordZoneChanges.filter { scope.contains($0) }
let contacts = self.appData.contacts
let batch = await CKSyncEngine.RecordZoneChangeBatch(pendingChanges: changes) { recordID in
// ====== How to determine from which array to fetch data for upload? Contacts or orders? ======
if let contact = contacts[recordID.recordName] {
let record = contact.lastKnownRecord ?? CKRecord(recordType: Contact.recordType, recordID: recordID)
contact.populateRecord(record)
return record
} else {
// We might have pending changes that no longer exist in our database. We can remove those from the state.
syncEngine.state.remove(pendingRecordZoneChanges: [ .saveRecord(recordID) ])
return nil
}
}
return batch
}
Assuming that two sets of data are stored locally
both of which are kept in sync with CloudKit. How to determine from which array to fetch data for upload at
nextRecordZoneChangeBatch
?