Please help me.
I want to get an object of data from http.
It works without problems with the code shown below.
However, if you can not access http, it takes time to process "Data (contentsOf: url)".
It will be around 20~30 seconds or so.
Please tell me about how I can deal with something.
---func---
let url = URL(string:"http://~~~~")!
var image: UIImage = UIImage()
autoreleasepool {
guard let sampleData = try? Data(contentsOf: url) else {
return
}
Image = UIImage(data: sampleData)!
}
DispatchQueue.main.async {
self.sampleView.image = Image
}
-----