'How to select all cells in a section except one cell in collectionview

I want to select all the cells in the section in collectionView but except one cell that can't be selected. I tried so many ways and searched a lot but no help. What I have now is only to select multiple cells in collectionView.

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    if deleteMode == true {
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Delete", style: .plain, target: self, action: #selector(tryThisMethod))
        self.collectionView.allowsMultipleSelection = true
        let cell = collectionView.cellForItem(at: indexPath) as! CollectionViewCell
        cell.toggleSelected()
        self.posiciones = collectionView.indexPathsForSelectedItems!
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source