I've been working on a project that needs to display an image fetched from a server using AlamofireImage. So my code goes like this:
import UIKit
import Alamofire
import AlamofireImage
@IBOutlet var imageView: UIImageView
func downloadImage() {
Alamofire.request(.GET, "http://www.axs.gt/wp-content/uploads/2016/05/tuzonapromo_600x.png").responseImage { (response) -> Void in
if let image = response.result.value {
imageView.image = image
}
}
It seems like the image is being downloaded but the imageView is not updating the new image fetched from the server. I must add that I'm able to download from HTTP and HTTPS since all the securities implications have been solved.
I also tried to do this
imageView.image = UIImage(named: "someImage")
And the imageView still doesn't update.
I would really appreciate any help.
So I was verifying the flow of my code and came to realization that I was trying to update my imageViews's image before the viewDidLoad method, which calls the super.viewDidLoad()
method, which is supposed to initialize everything in my View (aka setting the default image for my imageView). So what was actually happening was that I was fetching the image way before the compiler set the default image.
Thanks for the help.