class ViewController: UIViewController, UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { // Check whether there is any selected cell or not if collectionView.indexPathsForSelectedItems?.count ?? 0 > 0 { // if there is an already selected cells // check if selected cell indexPath is one of the indexPathsForSelectedItems if collectionView.indexPathsForSelectedItems!.contains(indexPath) { // if yes, deselect it collectionView.deselectItem(at: indexPath, animated: true) } else { // if no, not specified what to do here => personal suggestion would be to update the selected cells for row in 0.. Bool { // You can implement any logic you want here return true } }