PRADIP KUMAR PRADIP KUMAR - 4 months ago 92x
Swift Question

Download Image from Api Url and show in Collection view in swift using Alamofire

I already am able to fetch the url from the Api which is in Json format. But this one is the image url. now how can I able to download that image from url and show in collection view. I have


override func viewDidLoad() {

Alamofire.request(.GET, "http://\(platform)\(apiID)&app_key=\(apikey)&request=&request=gallery", parameters: nil)
.responseJSON { response in
print(response.request) // original URL request
print(response.response) // URL response
print( // server data
print(response.result) // result of response serialization

if let JSON = response.result.value {
print("JSON: \(JSON)")

self.imageData = JSON as! Array<AnyObject>
print("total number of images = \(self.imageData.count)")
for image in self.imageData{


all the image url are coming . I can see it. Now how to download image from that url and show in collection view. Please tell anyone how can I apply here.

The image url I got is:

total number of images = 16

Please tell the solution.

Ccr Ccr

Its easy to download image with Alamofire if you have imageURL.

make sure you have import AlamofireImage pod installed and you have

import AlamofireImage

    Alamofire.request(.GET, url) // url is string here.
                .responseImage { response in 
                    if let image = response.result.value {
                        // image is here. 
                        // check what happned.

more information can be found @