title: How to set the title of a UIButton in a UICollectionViewCell with Swift
body: <p>I have a ViewController with a UICollectionView where I'd like to display the first two letters of the players in the users friend list, like this: </p>
  
  <pre><code>func collectionView(collectionView: UICollectionView,
      cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
  
          contactListCollection.registerClass(PlayerCell.self, forCellWithReuseIdentifier: "PlayerCell")
  
          let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PlayerCell", forIndexPath: indexPath) as! PlayerCell
  
          let contacts = contactList.getContactList() //Array of strings
  
          for(var i = 0; i &lt; contacts.count; i++){
  
              var str = contacts[i]
              // First two letters
              let firstTwo = Range(start: str.startIndex,
                  end: str.startIndex.advancedBy(2))
  
              str = str.substringWithRange(firstTwo)
  
              cell.setButtonTitle(str);
          }
  
  
          return cell;
  }
  
  func collectionView(collectionView: UICollectionView,
    numberOfItemsInSection section: Int) -&gt; Int {
  
      return contactList.getContactList().count;
  }
  </code></pre>
  
  <p>My PlayerCell Class is as follows:</p>
  
  <pre><code>   class PlayerCell : UICollectionViewCell {
  
     @IBOutlet var button: UIButton?
  
     func setButtonTitle(text: String){
       button!.setTitle(text, forState: .Normal)
     }
  }
  </code></pre>
  
  <p>When run the code it gives: 
  <strong>Fatal error: unexpectedly found nil while unwrapping an Optional value</strong></p>
  
  <p>I found out that the button in my PlayerCell is nil</p>
  
  <p>I have added the button inside my cell in the Storyboard and Connected those with referencing outlets</p>
  
  <p>Am I missing something here?</p>
  
  <p>Using xCode 7 with Swift 2.0</p>