CKAsset and SDWebImage first time user

I have an array of CKRecords in an array. Using a table, im looking to use SDWedImage to act as a cache for the one CKAsset/Image in my Records. However, I'm having a difficult time creating a successful piece of code



    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!

}


However, with the use of the sd in code, I receive the "Cannot convert value of type 'Data' to expected argument type 'URL'?". How would I go about fixing this error? Is there an alternative to my let data constant that trys a URL instead of data?

Answered by Claude31 in 246213022

Did you try to pass a URL parameter ?


Something like

let theURL = URL(string: asset.fileURL) // not sure what type is asset.fileURL

cell?.restaurantImage.sd_setImage(with: theURL)

Accepted Answer

Did you try to pass a URL parameter ?


Something like

let theURL = URL(string: asset.fileURL) // not sure what type is asset.fileURL

cell?.restaurantImage.sd_setImage(with: theURL)

Yep, that's what fixed it lol. Thank you, kindly!

CKAsset and SDWebImage first time user
 
 
Q