title: Error casting value of type 'UICollectionReusableView' to 'MyApp.CSSectionHeader'
body: <p>I have the following class:</p>
  
  <pre><code>class CSSectionHeader: UICollectionReusableView {
  
      @IBOutlet var textLabel: UILabel!
  
  }
  </code></pre>
  
  <p>I'm then trying to cast it like the following:</p>
  
  <pre><code>override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -&gt; UICollectionReusableView {
  
      let cell1 = UICollectionReusableView()
  
      if (kind == UICollectionElementKindSectionHeader) {
          // Throws the cast error here:
          let cell: CSSectionHeader = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "sectionHeader", forIndexPath: indexPath) as! CSSectionHeader
  
          return cell
      } else if (kind == CSStickyHeaderParallaxHeader) {
          let cell: UICollectionReusableView = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "header", forIndexPath: indexPath) as! UICollectionReusableView
  
          return cell
      }
  
      return cell1
  }
  </code></pre>
  
  <p>The problem is I'm getting the following error:</p>
  
  <pre><code>Could not cast value of type 'UICollectionReusableView' (0x10ff4d140) to 'MyApp.CSSectionHeader' (0x10d775a70).
  </code></pre>