I am using swift and cloudkit trying to fetch images from cloudserver as below and I am getting error: "initializer of conditional binding must have optional type not CKAsset" at the line: if let ckAsset = image { please help as I am new to swift and this is my first app
let ckRecord = Saveddata[indexPath.row]
weak var weakCell = cell
backgroundQueue.addOperation {
let image = ckRecord.object(forKey: "Photos") as! CKAsset
if let ckAsset = image {
if let URL = ckAsset.fileURL {
let imagedata = NSData(contentsOf: URL)
OperationQueue.main.addOperation() {
cell.imageView?.image = UIImage(data: imagedata! as Data)
}
}
}