title: Download image from URL in loop for collection view
body: <p>Im trying to create a collection view of images.
  I've tried these solutions, to download the images:<br>
  <a href="https://teamtreehouse.com/community/does-anyone-know-how-to-show-an-image-from-url-with-swift" rel="nofollow noreferrer">one</a><br>
  <a href="https://stackoverflow.com/questions/24231680/loading-image-from-url">two</a><br>
  <a href="https://stackoverflow.com/questions/29472149/swift-how-to-display-an-image-using-url">three</a><br>
  And<br>
  <a href="https://github.com/hirohisa/ImageLoaderSwift" rel="nofollow noreferrer">four</a><br></p>
  
  <pre><code>var tempObject = json["photos"]
                  for var i = 0; i &lt; tempObject.count; i++
                  {
                      var tempImage = UIImage()
  
                      dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
  
                          tempImage =  UIImage(data: NSData(contentsOfURL: NSURL(string:"https://developer.apple.com/swift/images/swift-og.png")!)!)!
                      })
  
                      swiftImages.insert(tempImage, atIndex: i)
                  }
  
                  dispatch_async(dispatch_get_main_queue()) {
  
                      self.collectionView?.reloadData()
                  }
  </code></pre>
  
  <p>But i can't get it to display the images. I'm new to networking with swift.</p>
  
  <pre><code>func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
          let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! ImageCollectionViewCell
          cell.imageView.image = swiftImages[indexPath.row]
          return cell
      }
  </code></pre>