When should the cell be updated to display the downloaded image? If you execute self.collectionView?.reloadItems(at: [indexPath]) in completed: у метода sd_setImage , then a loop occurs

 override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: customCellIdentifier, for: indexPath) as! CustomCell cell.avatarImage.sd_setImage(with: URL(string: user[indexPath.row].avatarURL)!, placeholderImage: UIImage.defaultAvatar()) return cell } 

The same situation in AlamofireImage

  • Can I see all the code in question? - Max Mikheyenko

1 answer 1

 cell.avatarImage.sd_setImage(with: URL(string: user[indexPath.row].avatarURL)!, placeholderImage: UIImage.defaultAvatar(), options: SDWebImageOptions.retryFailed, completed: { (image, _, _, _) in cell.avatarImage.image = image })