我使用CoreData
爲應用程序。我在數據模型中將圖像設置爲BinaryData
。但是,我要取的圖像從服務器UIImage
和它拋出錯誤爲:無法指定'UIImage?'類型的值鍵入'NSData?'在迅速3
cannot assign value of type 'UIImage?' to type 'NSData?
我搜查,但找不到任何相似的解決方案。任何人都可以幫助我迅速3?
我的代碼是:
let url1:URL = URL(string:self.appDictionary.value(forKey: "image") as! String)!
let picture = "http://54.243.11.100/storage/images/news/f/"
let strInterval = String(format:"%@%@",picture as CVarArg,url1 as CVarArg) as String as String
let url = URL(string: strInterval as String)
SDWebImageManager.shared().downloadImage(with: url, options: [],progress: nil, completed: {[weak self] (image, error, cached, finished, url) in
if self != nil {
task.imagenews = image //Error:cannot assign value of type 'UIImage?' to type 'NSData?'
}
})
什麼是變量task.imagenews的類型? –
爲了幫助我們,我們需要更多。什麼是task.imagenews?你想用它做什麼? –