title: How to load image from url which I got via API calling
body: <p>I want to use <code>UICollectionView</code> for displaying the images and I am getting that images by api calling.</p>
  
  <p>Question: so I am getting images path via api calling so how can I display it to <code>UICollectionView</code>??</p>
  
  <p>here is my code ::</p>
  
  <pre><code>  func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
  
      let dic = imagearray .objectAtIndex(indexPath.row) as! NSDictionary
      let cell :imagecell = collectionView.dequeueReusableCellWithReuseIdentifier("imagecell", forIndexPath: indexPath) as! imagecell
  
      cell.imagev.image = dic["image"] as? UIImage
      return cell
  }
  </code></pre>
  
  <p>and here is my api response</p>
  
  <pre><code>(
      {
      image = "http://radio.spainmedia.es/wp-content/uploads/2015/12/esquire.jpg";
      slug = esquire;
  },
      {
      image = "http://radio.spainmedia.es/wp-content/uploads/2015/12/forbes.jpg";
      slug = forbes;
  },
      {
      image = "http://radio.spainmedia.es/wp-content/uploads/2015/12/tapas.jpg";
      slug = tapas;
  }
  )
  </code></pre>
  
  <p>so how can I display this images in my <code>UICollectionView</code></p>
  
  <p>UPDATE:: While using commented code getting strange issue i am calling my webservice in viewdidload </p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      webimages()
  
      // Do any additional setup after loading the view, typically from a nib.
  }
  </code></pre>
  
  <p>and its started to call webservice</p>
  
  <pre><code>func webimages()
  {
  
  let url = "http://radio.spainmedia.es/podcasts/"
  
      request(.GET, url, parameters: nil, encoding: .JSON).responseJSON { (response:Response&lt;AnyObject, NSError&gt;) -&gt; Void in
  
  
             print(response.result.value)
  
              self.imagearray = (response.result.value) as! NSMutableArray
              print(self.imagearray)
  
  
      }
  
  }
  </code></pre>
  
  <p>but after requesting its suddenly go to cellForItemAtIndexPath so my "imagearray" found nil there. and then its comeback to webimages() and giving me api response.</p>
  
  <p>So how can I solve this?</p>
  
  <p><a href="http://i.stack.imgur.com/qR3nK.png" rel="nofollow">we have array of string we are passing single string here so can you please tell me that what is the solution</a></p>
  
  <p>We have array of string we are passing single string here so can you please tell me that what is the solution</p>
  
  <p><a href="http://i.stack.imgur.com/bfyPu.png" rel="nofollow">enter image description here</a></p>