It seems to be a silly question, but I'm pretty new with Swift.
I want to download PNG image from https://httpbin.org/image/png and make it show in my UIImageView
which has the name imageView
, but it's not working.
[Result]: SUCCESS: , {33.333333333333336, 33.333333333333336} [Timeline]: Timeline: { "Request Start Time": 527346831.982, "Initial Response Time": 527346833.435, "Request Completed Time": 527346833.437, "Serialization Completed Time": 527346833.468, "Latency": 1.453 secs, "Request Duration": 1.455 secs, "Serialization Duration": 0.031 secs, "Total Duration": 1.486 secs } SUCCESS: , {33.333333333333336, 33.333333333333336} image downloaded: , {33.333333333333336, 33.333333333333336}
import UIKit
import Alamofire
import AlamofireImage
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
Alamofire.request("https://httpbin.org/image/png").responseImage { response in
debugPrint(response)
debugPrint(response.result)
if let imageView = response.result.value {
print("image downloaded: \(imageView)")
}
}
}
}
You did not set the image as your
imageView
'simage
. Here is your code, fixed: