title: Swift 3 UICollectionView Error
body: <p>In my iOS app, I have a UICollectionView controller with the following code inside:</p>
  
  <pre><code>var images = [UIImage]()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      loadImages()
      // Register cell classes
  }
  
  func loadImages() {
      images.append(UIImage(named: "ActivityTab")!)
      self.collectionView?.reloadData()
  }
  
  override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      // #warning Incomplete implementation, return the number of items
      return images.count
  }
  
  override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! EventCollectionViewCell
  
      let image = images[indexPath.row]
  
      cell.imageView.image = image
  
      return cell
  }
  </code></pre>
  
  <p>And I have a UICollectionViewCell (EventCollectionViewCell) with the following code:</p>
  
  <pre><code>@IBOutlet weak var imageView: UIImageView!
  
  override func prepareForReuse() {
      super.prepareForReuse()
      self.imageView.image = nil
  }
  </code></pre>
  
  <p>I have linked everything up with the storyboard too. This looks like it should work but I get the following error: </p>
  
  <blockquote>
    <p>Could not cast value of type 'UICollectionViewCell' (0x1092c04a8) to EventCollectionViewCell'</p>
  </blockquote>
  
  <p>Does anyone know what the error is and how to fix it. It only shows when I return images.count in the number of sections.</p>
  
  <p>I am using xcode 9 but have tried with xcode 8 and the error still persists. Any help would be greatly appreciated. :)</p>