nil label for custom UICollectionCell
<p><strong>EDIT</strong>: seems like same question as <a href="https://stackoverflow.com/questions/25165195/why-is-uicollectionviewcells-outlet-nil?lq=1">this</a><br>
I made collection view with custom layout and cell but my cell's positions were a little off so I decided to number them so that I could debug it easier. I followed this guy's <a href="https://stackoverflow.com/questions/31735228/how-to-make-a-simple-collection-view-with-swift/31735229#31735229">answer</a> to number my cell using labels. Somehow <code>myLabel</code> was nil and caused my app to crash.</p>

<p>I believe I have connected the outlets correctly but maybe someone could provide a list for me to check if I am doing anything wrong.</p>

<h2>ViewController</h2>

<pre><code>import UIKit

class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {

  @IBOutlet var gridView: UICollectionView!

  private let reuseIdentifier = "DesignCell"
  private let numberOfSections = 1
  private let numberOfCircles = 48

  override func viewDidLoad() {
    super.viewDidLoad()
    self.gridView.registerClass(MyCell.self, forCellWithReuseIdentifier: reuseIdentifier)
  }

  func numberOfSectionsInCollectionView(collectionView: UICollectionView) -&gt; Int {
    return numberOfSections
  }

  func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
    return numberOfCircles
  }

  func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {

    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MyCell

    cell.myLabel.text = String(indexPath.item) // myLabel is nil and causes a crash
    return cell
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
  }

}
</code></pre>

<h2>GridLayout (my custom layout)</h2>

<pre><code>import UIKit
import Darwin

class GridLayout: UICollectionViewLayout {

  private let numberOfColumns = 12
  private let numberOfRows = 4

  private var cache = [UICollectionViewLayoutAttributes]()
  private var contentHeight: CGFloat = 0
  private var contentWidth: CGFloat {
    let insets = collectionView!.contentInset
    return CGRectGetWidth(collectionView!.bounds) - insets.left - insets.right
  }

  override func prepareLayout() {
    // some calculation i did for my cells
  }

  override func collectionViewContentSize() -&gt; CGSize {
    return CGSize(width: contentWidth, height: contentHeight)
  }

  override func layoutAttributesForElementsInRect(rect: CGRect) -&gt; [UICollectionViewLayoutAttributes]? {
    var layoutAttributes = [UICollectionViewLayoutAttributes]()

    for attr in cache {
      if CGRectIntersectsRect(attr.frame, rect) {
        layoutAttributes.append(attr)
      }
    }
    return layoutAttributes
  }
}
</code></pre>

<h2>MyCell</h2>

<pre><code>import UIKit

class MyCell : UICollectionViewCell {

  @IBOutlet weak var myLabel: UILabel!

}
</code></pre>