title: Swift: Prepare for segue not passing data
body: <p>I have got a collection view inside a table view (Netflix App Style). I followed this tutorial: <a href="https://www.thorntech.com/2016/01/scrolling-in-two-directions-like-netflix-part-2-making-api-calls/" rel="nofollow noreferrer">https://www.thorntech.com/2016/01/scrolling-in-two-directions-like-netflix-part-2-making-api-calls/</a></p>
  
  <p>Now I want to implement a function that whenever I click on a collection view, it will pass the employee's name to the next view controller.
  Here is my code:</p>
  
  <pre><code>import UIKit
  
  class CategoryRow: UITableViewCell, UICollectionViewDataSource {
  
      @IBOutlet weak var collectionView: UICollectionView!
  
      var jobpost:JobPosition?
      var employee: Employee?
  
      var myname = ""
  
  
      func collectionView(_ collectionView: UICollectionView,     numberOfItemsInSection section: Int) -&gt; Int {
          return jobpost!.Employees.count
      }
  
      func collectionView(_ collectionView: UICollectionView,     cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "videoCell", for: indexPath) as! EmployeeCell
      cell.employeephoto.image = UIImage(named: "spanner")
  
      cell.employeename.text = jobpost?.Employees[indexPath.row].name
  
      return cell
  }
  
  func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
      let myname = jobpost?.Employees[indexPath.row].name
      //print(myname)
  }
  
  func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
  
          let EmployeeDetailPage = segue.destination as? EmployeeDetailViewController
  
          EmployeeDetailPage?.employeename = myname
          print(myname)
  }
  </code></pre>
  
  <p>Now my problem is, the whole PrepareForSegue function didn't actually run. The app runs normally without any error but the data just didn't pass through? (i.e. the print(myname) didn't actually print anything).</p>
  
  <p>Is there something I missed out? Very much appreciated.</p>