title: Swift - Selecting item in Collection View
body: <p>I'm having a problem with selected items in a collection view.</p>
  
  <p>Selected items change backgroundColor to blue, but it seems like the reusable cells are also affected.</p>
  
  <p>my code looks like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    var cell = collectionView.cellForItemAtIndexPath(indexPath) as UICollectionViewCell?
    cell?.contentView.backgroundColor = UIColor.blueColor()
  
  func collectionView(collectionView: UICollectionView, didDeslectItemAtIndexPath indexPath: NSIndexPath) {
    var cell = collectionView.cellForItemAtIndexPath(indexPath) as UICollectionViewCell?
    cell?.contentView.backgroundColor = UIColor.blackColor()
  }
  
  func collectionView(collectionView: UIControllerView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
    let cell: boxCell = collectionView.dequeueReusableCellWithReuseIdentifier("demoCell", forIndexPath: indexPath) as boxCell
  
    cell.cellTitle.text = name[indexPath.row]
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>When I run the application, the selection works, selecting another cell, deselects the other selected cells, but when I scroll, the reusable cells are also turning blue.</p>
  
  <p>I am using a horizontal scroll direction with only 1 row and 4 cells per row.</p>
  
  <p>Where did I go wrong? Anybody else have had this issue?</p>