title: How to get cell atIndex in UICollectionView with swift?
body: <p>I am making Collection view programatically.
  Here is the code in viewDidLoad func</p>
  
  <pre><code>let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
      layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
      layout.itemSize = CGSize(width: 90, height: 120)
      collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
      collectionView!.dataSource = self
      collectionView!.delegate = self
      collectionView!.registerClass(CollectionViewCell.self, forCellWithReuseIdentifier: "CollectionViewCell")
      collectionView!.layer.cornerRadius = 2
      collectionView!.backgroundColor = UIColor.redColor()
      self.containerView.addSubview(collectionView!)
  </code></pre>
  
  <p>And these are my collection view functions</p>
  
  <pre><code>func numberOfSectionsInCollectionView(collectionView: UICollectionView) -&gt; Int {
      return 1
  }
  
  func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 8
  }
  
  func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
      cell.backgroundColor = UIColor.blackColor()
      cell.buttonView.addTarget(self, action: Selector("Action\(indexPath.row):"), forControlEvents: UIControlEvents.TouchUpInside)
      return cell
  }
  </code></pre>
  
  <p>Idea is I have a button in the cell, and when I press it the cell should change color, here is the action function</p>
  
  <pre><code>func Action0(sender: UIButton!) {
      var indexPath = NSIndexPath(forRow: 0, inSection: 0)
      let cell = collectionView!.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath ) as! CollectionViewCell
      cell.backgroundColor = UIColor.blueColor()
  </code></pre>
  
  <p>and this is collectionViewCell class, </p>
  
  <pre><code>class CollectionViewCell: UICollectionViewCell {
  
  required init(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  }
  
  var buttonView: UIButton!
  override init(frame: CGRect) {
      super.init(frame: frame)
  
      buttonView = UIButton.buttonWithType(UIButtonType.System) as! UIButton
      buttonView.frame = CGRect(x: 0, y: 16, width: frame.size.width, height: frame.size.height*2/3)
  
      contentView.addSubview(buttonView)
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The button and the action works but the cell doesn't change colour, i guess the problem is in this line</p>
  
  <pre><code>let cell = collectionView!.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath ) as! CollectionViewCell
  </code></pre>