What is a bridging conversion in Swift as in the following warning: Conditional downcast from 'Data?' to 'CKRecordValue is a bridging conversion

What is a bridging conversion in Swift? My other post asking this question didn't get an explanation, though I did get a solution to the problem.


import UIKit
import CloudKit

let int: UInt8 = 1
let data: Data? = Data([int])
let record: CKRecord = CKRecord(recordType: "record_type")
record.setObject(data as? CKRecordValue, forKey: "field") // warning:


I get a warning in the following code where I marked with a comment saying "// warning":

The warning says:

Conditional downcast from 'Data?' to 'CKRecordValue' (aka '__CKRecordObjCValue') is a bridging conversion; did you mean to use 'as'?

Replies

This could give you some detail explanation on bridging (which is allowing call objC from Swift, as __CKRecordObjCValue is objC):

h ttps://medium.com/the-mobile-company/converting-objective-c-to-swift-a-close-look-a1b916f2ac35


Other post, did you mean your 2017 post on this topic ? Isn't the answer there ?

https://forums.developer.apple.com/thread/75981