title: Clicking a thumbnail in a uicollectionviewcell and displaying full image in a new view
body: <p>I am using a UIViewController with a UICollectionView to render a series of thumbnails to in the view.</p>
  
  <p>When the user clicks the thumbnail it should bring them to a new scene that displays the full image.</p>
  
  <p>I tried using <code>didSelectItemAt</code> to implement this but when testing it no output log is produced:</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
      print("Selecting item #\(indexPath.row)")
  }
  </code></pre>
  
  <p>The thumbnail pictures are displayed properly with the following:</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = imageCollection.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)as! ImageGalleryCell
  
      if cellCount &lt; imageArray.count{
          print("Cell Count: ", cellCount)
  
          let url = URL(string: "https://myurl.com\(imageArray[cellCount])")
          print("url: ", url!)
         cell.images.sd_setImage(with: url, placeholderImage: UIImage(named: "someImage"))
      }
      cellCount += 1
      return cell
  }
  </code></pre>
  
  <p>Is <code>didSelectItemAt</code>  the proper method to use to click an thumbnail image and display a full image in a new view?</p>
  
  <p>EDIT: I tried to use a segue as follows:</p>
  
  <pre><code> `override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      if segue.identifier == "toFullImage"{
          if let toFullImage = segue.destination as? ImagePageController{
              toFullImage.fullImage = UIImage(named: fullImageArray[0])!
          }
      }
  }`
  </code></pre>
  
  <p>But when I click on an image the app crashes and I get an error saying: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value</p>
  
  <p>Is it possible to fix it so it can work with segue or is this completely wrong?</p>