For the record block, let’s compare their signatures (adding some handy names and spacing for clarity):
typealias OldRecordFetchedBlock = ( CKRecord ) -> Void
typealias NewRecordMatchedBlock = (CKRecord.ID, Result<CKRecord, Error>) -> Void
The main change is the CKRecord is now wrapped in a Result, so it can indicate that either a record was successfully fetched, or if an error occurred. You just need to unpack the record from the Result in order to use it:
operation.recordMatchedBlock = { id, result in
switch result {
case .success(let record):
self.saveToCoreData(record: record)
case .failure(let error):
// handle the error in some way
}
}
The change from queryCompletionBlock to queryResultBlock is similar. The cursor and error are now wrapped in a Result rather than being separate parameters.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: