第一次将 CKAsset 与 SDWebImage 一起使用 - 无法将数据转换为 URL

Using a CKAsset with SDWebImage for the first time - cannot convert Data to URL

我在数组中有一个 CKRecords 的数组。使用 table,我希望使用 SDWedImage 作为我的记录中 CKAsset/Image 的缓存。

我试过的代码:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "restaurantcell") as? RestaurantTableCell

    cell?.dealsicon.layer.cornerRadius = 3

    let restaurant: CKRecord = restaurantArray[indexPath.row]

    let asset = restaurant.value(forKey: "Picture") as! CKAsset

    let data = try! Data(contentsOf: asset.fileURL)    

    cell?.restaurantImage.sd_setImage(with: data)

    return cell!
}

但是,在代码中使用 sd 时,我收到以下错误,

Cannot convert value of type 'Data' to expected argument type 'URL'?.

我该如何解决这个错误?

是否有替代我的常量 data 的方法尝试使用 URL 而不是数据?

如果错误发生在这块.sd_setImage(with: data)上,则不需要从URL中得到Data。因为,sd_setImage参数是URL.

尝试下面的代码,

cell?.restaurantImage.sd_setImage(with: asset.fileURL)