title: Subclass UICollectionView
body: <p>So, I need to extend <code>UICollectionView</code> functionality, override Cells, etc.
  In every example I see subclassing of <code>UICollectionViewController</code>, but not just <code>UICollectionView</code>.</p>
  
  <p>I don't want to make my new class (called <code>GridSet</code>) as superclass for a single page (<code>UIViewController</code>) in storyboard, cause I have more elements (custom buttons, labels etc) and I don't want to maintain them in my new class, but I want to maintain them in a my page <code>UIViewController</code>.</p>
  
  <p>I even want to insert two of my subclasses in one <code>UIViewController</code> and do it in storyboard (but you can't place one <code>UIViewController</code> inside another <code>UIViewController</code>.</p>
  
  <p>The problem is, when I'm subclassing <code>UICollectionView</code> and <code>UICollectionViewDataSource</code>, seems like it even don't initialize.</p>
  
  <pre><code>class GridSet: UICollectionView, UICollectionViewDataSource {
  
  let computers = [
      ["Name" : "MacBook Air", "Color" : "Silver"],
      ["Name" : "MacBook Pro", "Color" : "Silver"],
      ["Name" : "iMac", "Color" : "Silver"],
      ["Name" : "Mac Mini", "Color" : "Silver"],
      ["Name" : "Mac Pro", "Color" : "Black"]
  ]
  
  override func awakeFromNib() {
      super.awakeFromNib()
  
      let nib = UINib(nibName: "GridSetCell", bundle: nil)
      self.registerNib(nib, forCellWithReuseIdentifier: "GridSetCellDefault")
  }
  
  func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return computers.count
  }
  
  func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
      let cell = self.dequeueReusableCellWithReuseIdentifier("GridSetCellDefault", forIndexPath: indexPath) as GridSetCell
  
      cell.label = computers[indexPath.row]["Name"]!
  
      return cell
  }
  
  }
  </code></pre>
  
  <p>I use nib for custom cell:</p>
  
  <pre><code>class GridSetCell: UICollectionViewCell {
  
  @IBOutlet private weak var cLabel: UILabel!
  @IBOutlet private weak var cBack: UIImageView!
  
  var label: String = "" {
      didSet {
          if (label != oldValue) {
              cLabel.text = label
          }
      }
  }
  
  var back: String = "" {
      didSet {
          if (back != oldValue) {
              cBack.image = UIImage(named: back)
          }
      }
  }
  
  }
  </code></pre>