patrickb100
patrickb100

Reputation: 51

Alamofire return jpg image to Xcode

I am using alamofire to retreive an image from a webservice. The .jpg image is returned in the body of the response.

Can anybody guide me on how to display the retreived image on a uiImageView?

Thanks in advance, Patrick

Upvotes: 0

Views: 121

Answers (1)

zeytin
zeytin

Reputation: 5643

From my understanding, you have already imageUrl and no restriction 3rd party libraries as you have also used Alamofire, so I think Kingfisher can come into play like this function :

func setup(imageUrl: String?) {
    if let imageUrl = imageUrl,
       let url = URL(string: imageUrl) {
        imageView.kf.setImage(with: url, placeholder: UIImage(named: "placeholderImage"))
    } else {
        imageView.image = UIImage(named: "placeholderImage")
    }
}

Upvotes: 2

Related Questions