I have an array of CKRecords
in an array. Using a table, I am looking to use SDWedImage
to act as a cache for the one CKAsset/Image in my Records.
Code I have tried:
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 below error,
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 constant data
that trys a URL instead of data?
If the error occur on this piece .sd_setImage(with: data)
, then not need to get Data
from URL
. Because, sd_setImage
parameter is URL
.
Try Below Code,
cell?.restaurantImage.sd_setImage(with: asset.fileURL)