Skip to content

Instantly share code, notes, and snippets.

@cnharris10
Created April 18, 2016 00:52
Show Gist options
  • Save cnharris10/72bcf7239875b667b08eacee8b1ec385 to your computer and use it in GitHub Desktop.
Save cnharris10/72bcf7239875b667b08eacee8b1ec385 to your computer and use it in GitHub Desktop.
import HanekeSwift
override viewDidLoad() {
let cache = Cache<JSON>(name: "github") // Set as instance variable
cacheImages()
refreshItems()
}
func cacheImages() {
for image in arrayOfImages {
let url = NSURL(string: image.url)!
cache.fetch(URL: url).onSuccess { JSON in
print(JSON.dictionary?["bio"])
}
}
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("imageReuseCell", forIndexPath: indexPath) as! ImageCollectionViewCell
let image = hingeImagesArray[indexPath.row]
if let imageURL = image.imageUrl as? NSURL {
cell.collectionView.image = hnk_setImageFromURL(imageUrl!)
}
return cell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment