How to asynchronous load image from a web-server in UICollectionView using NSCache

Try this one it’s Working code (Swift 4). func NKPlaceholderImage(image:UIImage?, imageView:UIImageView?,imgUrl:String,compate:@escaping (UIImage?) -> Void){ if image != nil && imageView != nil { imageView!.image = image! } var urlcatch = imgUrl.replacingOccurrences(of: “https://stackoverflow.com/”, with: “#”) let documentpath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] urlcatch = documentpath + “https://stackoverflow.com/” + “\(urlcatch)” let image = UIImage(contentsOfFile:urlcatch) if image != nil … Read more