iosswiftcachinghaneke

Cache image and show them using Haneke


I'm trying to cache (Haneke) an image and show it but i can't seem to figure out the first UIImage parameter in the hnk_setImage. How can i show the image from the logoCache key?

Cache Image

cache.set(value: logoData, key: logoCache)

Fetch and Show Image

cell.customerImageView?.hnk_setImage(UIImage?, key: logoCache)

Solution

  • var mArray = [[String:AnyObject]]()
    

    inside cellForItemAtIndexPath function

    var var1 = mArray[indexPath.row]
    
        let ImageURLKey = var1["logoCache"] as! String
    
    if let url =  NSURL(string: "yourUrl/"+ImageURLKey) {
            cell.imageView.contentMode = UIViewContentMode.ScaleAspectFit
             cell.imageView.hnk_setImageFromURL(url)
    
        }