I have a URL and want to download the image via a return function, however I cant get it to cooperate properly, here is my func:
func getTabImage(url: URL) -> UIImage {
Alamofire.request(url)
.responseImage { response in
if let image = response.result.value {
return image
} else {
print("Failed to get image")
}
}
}
I pass in the URL, and want a UIImage returned from the alamofire response.
But i get
Unexpected non-void return value in void function
for the return statement.
How can i achieve this correctly?
You can use the below function for downloading the image:
Uses
Or
If you want to set the image on
UIImageView
use extension of AlamofireImage.