modifyRecordsCompletionBlock deprecated on iOS 15

I want to target iOS 15 and I get deprecation warnings in some CloudKit properties. I was using modifyRecordsCompletionBlock on CKModifyRecordsOperation and now I get:

'modifyRecordsCompletionBlock' was deprecated in iOS 15.0: Use modifyRecordsResultBlock instead

However with modifyRecordsCompletionBlock I'd get an array of the successfully modified records as input for the block which I'd in turn use for updating my local DB, whereas the input for modifyRecordsResultBlock is Result<Void, Error>.

Basically I'm being told to use a different closure where I get no data and I don't know how to complete my local DB updates.

Any ideas?

Post not yet marked as solved Up vote post of gbuela Down vote post of gbuela
1.7k views

Replies

Supply a perRecordSaveBlock and perRecordDeleteBlock within that operation and maintain the cumulative results there, leaving the modifyRecordsResultBlock free to describe the operation as a whole.

Watch this video and it will describe the enhancements made this year in full detail for the new resultBlock closures (and new async methods too!) Having migrated over to the new API, it is really a nice update though some of my closures were gnarly (doing atomic processing with records that referenced each other as an example).

What's New in CloudKit WWDC21

  • I think the async methods are just auto-generated by Swift, I don't think they actually coded anything. Also they don't support task cancellation so pretty useless for SwiftUI's task modifier.

Add a Comment

I think we have to keep using modifyRecordsCompletionBlock because modifyRecordsResultBlock doesn't error on server record changed, it erroneously reports success. As of Xcode 14b1 iOS 16b1. See this post for more info.