Toggle image in UICollectionViewCell when cell selected
<p>I have a UICollectionView of items, and I would like an image in a cell to be toggled when the user selects the cell.</p>

<p>I have a custom UICollectionViewCell:</p>

<pre><code>class RDCell: UICollectionViewCell {

var textLabel: UILabel!
var imageView: UIImageView!
var isSelected: Bool!

...(do init and all that good stuff)

}
</code></pre>

<p>And selctected item in collection view :</p>

<pre><code>func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -&gt; Bool {

    let celld = (collectionView.dequeueReusableCellWithReuseIdentifier("collectionCell", forIndexPath: indexPath) as? RDCell)!

    let indexPaths = collectionView.indexPathsForSelectedItems()

    let newCell = collectionView.cellForItemAtIndexPath(indexPath) as! RDCell
    if(celld.selected){

        var image: UIImage = UIImage(named: "notSelected")!
        newCell.imageView.image = image

        newCell.selected = false
    }else{
        var image: UIImage = UIImage(named: "selected")!
        newCell.imageView.image = image

        newCell.selected = true
    }

return true
}
</code></pre>

<p>My attempt partially works, after selecting and unselecting one item I am not able to select it again after, I need to select a different cell before returning to select the first, and this same bug happens on all selected cells.</p>

<p>Any suggestions or another way to implement the functionality I seek would be greatly appreciated. </p>