How can I place images in array which is downloaded by Kingfisher cache?

Viewed 834

This is my Swift 3 code. I need to place the images into an array which is downloading through Kingfisher cache. Actually, the image is now displaying in the cell.itemImage, but I am not able to put those images to a UIImage array.

Can anyone help?

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! ViewItemsCVC
    let Currency = UserDefaults.standard.string(forKey: "currency")
    cell.NameLabel.text = self.itemName[indexPath.row]
    cell.PriceLabel.text = "\(Currency ?? "INR")  \(self.itemPrice[indexPath.row])"
    let resource = ImageResource(downloadURL: URL(string: self.FullLink[indexPath.row])!, cacheKey: self.FullLink[indexPath.row])
    cell.itemImage?.kf.setImage(with: resource)
    return cell
}
2 Answers
Related