title: Swift: Click onto cell of UICollectionView and open AlertViewController
body: <p>In my app, I am using an UICollectionView. Now I want to develop an UIAlertController, when clicking onto any cell of the collection view.
  I started with following code:</p>
  
  <pre><code>extension HomeViewController: UICollectionViewDataSource {
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      …
  }
  
  // specify cells
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      ….
  }
  
  // called when widget is moved
  func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
          …
  }
  
  // called when clicked
  func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
      print("Got clicked!")
  }
  
  }
  </code></pre>
  
  <p>But somehow, "Got clicked!" is never printed.</p>