I would like to add a checkmark to a selected cell. If the cell is then deselected (and thus another is selected), I would like to remove the checkmark. The top image view is independent from the collection view and represents the selected cell from a user's Camera Roll. The collection view's data source is the list of images fetched from PHAssets.

The problem is that if I don't reload the item at the indexPath, the deselected cell checkmark doesn't get removed. Also, if I scroll through the collection view, I'll see random checkmarks from cells I didn't even tap. I'm assuming it has to do with the reusing of the cells. Can anyone please help me?

Below is snippets of my code from the view controller and the cell...

```
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: photoCellReuseIdentifier, for: indexPath) as? PhotosCell else { fatalError("Couldn't return a photo cell") }
    let requestOptions = PHImageRequestOptions()
    requestOptions.isSynchronous = true
    requestOptions.isNetworkAccessAllowed = true
    requestOptions.deliveryMode = .highQualityFormat

    photoManager.requestImage(for: photoAssets![indexPath.row], targetSize: CGSize(width: 100, height: 100), contentMode: .aspectFill, options: requestOptions, resultHandler: { (image, nil) in
        cell.photoView.image = image
    })

    if cell.isSelected {
        cell.setupCheckmarkBanner()
    }
    else {
        cell.removeCheckmarkBanner()
    }

    if indexPath.row == 0 && self.isFirstLoad {
        self.selectedImageView.image = cell.photoView.image
        collectionView.selectItem(at: indexPath, animated: false, scrollPosition: UICollectionViewScrollPosition.bottom)
        cell.setupCheckmarkBanner()
        self.isFirstLoad = false
    }

    return cell
}

func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
    previousIndexPath = indexPath
    collectionView.reloadItems(at: [indexPath])
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    if previousIndexPath != indexPath {
        collectionView.reloadItems(at: [indexPath])
        guard let cell = collectionView.cellForItem(at: indexPath) as? PhotosCell else { fatalError("Couldn't return a photo cell") }
        selectedImageView.image = cell.photoView.image
    }
}

class PhotosCell: UICollectionViewCell {

let photoView = UIImageView()
var checkmarkBannerImageView: UIImageView? 

override init(frame: CGRect) {
    super.init(frame: frame)
    addSubview(photoView)
    photoView.anchor(top: topAnchor, left: leadingAnchor, bottom: bottomAnchor, right: trailingAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: 0, height: 0)
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

func setupCheckmarkBanner() {
    checkmarkBannerImageView = UIImageView(image: #imageLiteral(resourceName: "check").withRenderingMode(.alwaysTemplate))
    checkmarkBannerImageView?.contentMode = .center
    checkmarkBannerImageView?.contentScaleFactor = 4.0
    checkmarkBannerImageView?.tintColor = .white
    checkmarkBannerImageView?.setBottomBorder(for: .white)
    checkmarkBannerImageView?.convertToCircle(value: 12)

    photoView.addSubview(checkmarkBannerImageView!)
    checkmarkBannerImageView?.anchor(top: photoView.topAnchor, left: nil, bottom: nil, right: photoView.trailingAnchor, paddingTop: 4, paddingLeft: 0, paddingBottom: 0, paddingRight: 4, width: 24, height: 24)
}

func removeCheckmarkBanner() {
    checkmarkBannerImageView?.removeFromSuperview()
    checkmarkBannerImageView?.constraints.forEach{$0.isActive = false }
    checkmarkBannerImageView = nil
}
}

```

[![Selecting a Dish](https://i.stack.imgur.com/nvd4u.jpg)](https://i.stack.imgur.com/nvd4u.jpg)