我有一个Medicine结构,其中包含我想要下载的图像的image_origin地址,并将其设置为ImageView。出于下载/缓存的目的,我使用了Kingfisher框架。
let m = medicines[indexPath.row]
cell.medicineImage.kf.setImage(with: URL(string: m.value(forKeyPath: "image_origin") as! String)!)
cell.medicineName.text = m.value(forKeyPath: "i_name") as? String在上面的代码中,m是CoreData的NSManagedObject。我尝试从CoreData获取图像URI并将其设置为ImageView,但每次在第2行我都会收到以下错误消息:Unexpectedly found nil while unwrapping an Optional value
我尝试过改变变量和Optinal类型,尝试硬编码URI,但是没有成功。
我做错了什么?
附注:即时通信使用Swift4
https://stackoverflow.com/questions/51459738
复制相似问题