Im trying to create a collection view of images.
I've tried these solutions, to download the images:
one
two
three
And
four
var tempObject = json["photos"]
for var i = 0; i < 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()
}
But i can't get it to display the images. I'm new to networking with swift.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! ImageCollectionViewCell
cell.imageView.image = swiftImages[indexPath.row]
return cell
}