Search code examples
iosswiftcloudkit

Cannot convert ZoneConfiguration to ZoneOptions


As ZoneOptions is deprecated, I changed optionsByRecordZoneID variable to ZoneConfiguration as follows

   var optionsByRecordZoneID = [CKRecordZone.ID: CKFetchRecordZoneChangesOperation.ZoneConfiguration]()

   for zoneID in zoneIDs {
            let options = CKFetchRecordZoneChangesOperation.ZoneConfiguration()
            options.previousServerChangeToken = settings.getChangeToken(forKey: databaseTokenKey)
            optionsByRecordZoneID[zoneID] = options
        }

Now, I am getting the following error for this line for optionsByRecordZoneID variable,

let fetchRecordZoneChangesOperation = CKFetchRecordZoneChangesOperation(recordZoneIDs: zoneIDs, optionsByRecordZoneID: optionsByRecordZoneID)

Cannot convert value of type '[CKRecordZone.ID : CKFetchRecordZoneChangesOperation.ZoneConfiguration]' to expected argument type '[CKRecordZone.ID : CKFetchRecordZoneChangesOperation.ZoneOptions]?'

Any help in regard to get rid of it would be appreciated.


Solution

  • The init(recordZoneIDs:,optionsByRecordZoneID:) is deprecated too since it takes the old ZoneOptions.

    Use init(recordZoneIDs:,configurationsByRecordZoneID:).

    let fetchRecordZoneChangesOperation = CKFetchRecordZoneChangesOperation(recordZoneIDs: zoneIDs, configurationsByRecordZoneID: optionsByRecordZoneID)