Manos Chorianopoulos

fix null merchant image crash

......@@ -237,21 +237,22 @@ extension UIImage {
} else {
//No cache, so create new one and set image
let url = URL(string: urlString)
URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) in
if let error = error {
print(error)
return
}
DispatchQueue.main.async(execute: {
if let downloadedImage = UIImage(data: data!) {
imageCache.setObject(downloadedImage, forKey: urlString as NSString)
completion(downloadedImage)
if let url = URL(string: urlString) {
URLSession.shared.dataTask(with: url, completionHandler: { (data, response, error) in
if let error = error {
print(error)
return
}
})
}).resume()
DispatchQueue.main.async(execute: {
if let downloadedImage = UIImage(data: data!) {
imageCache.setObject(downloadedImage, forKey: urlString as NSString)
completion(downloadedImage)
}
})
}).resume()
}
}
}
}
......