We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 684cce6 commit 1ea08b8Copy full SHA for 1ea08b8
HttpUtility/Extensions/UIImageViewExtension.swift
@@ -11,19 +11,17 @@ import UIKit
11
12
extension UIImageView
13
{
14
- func downloadImageFromUrl(urlString: String)
+ func downloadImageFromUrl(imageUrl: URL, placeHolderImage: String)
15
16
- let url = URL(string: urlString)!
17
-
18
- URLSession.shared.dataTask(with: url) { (data, response, error) in
19
20
- if(data != nil)
21
- {
22
- DispatchQueue.main.async {
23
- self.image = UIImage(data: data!)
+ self.image = UIImage(named: placeHolderImage)
+ DispatchQueue.global().async { [weak self] in
+ if let data = try? Data(contentsOf: imageUrl){
+ if let image = UIImage(data: data){
+ DispatchQueue.main.async {
+ self?.image = image
+ }
24
}
25
26
- }.resume()
27
28
29
0 commit comments