title: Swift - didSelectRowAt indexPath next VC not showing up /no storyboards/
body: <p>I have a problem with "didSelectRowAt indexPath" because row is not firing next VC.
  In console I've printed string for particular row so selecting a row is working however next VC is not opening.
  I've of course tried to find a solution on stack overflow and google however I cannot find a solution.
  Below I'm pasting:
  MainVC -> ViewController 
  and 
  next VC -> DetailViewCOntroller</p>
  
  <p>Thank you in advance for your help.</p>
  
  <p>Main VC:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
    let cellID = "Picture"
    let tableViewCell = TableViewCell()
  
    let tableWithImages: UITableView = {
      let table = UITableView()
      table.rowHeight = 50
      table.translatesAutoresizingMaskIntoConstraints = false
      return table
    }()
  
    var pictures: [String] = [String]()
  
    override func viewDidLoad() {
      super.viewDidLoad()
      view.backgroundColor = .white
      tableWithImages.delegate = self
      tableWithImages.dataSource = self
      tableWithImages.register(TableViewCell.self, forCellReuseIdentifier: cellID)
      fileManagerSetup()
      setupView()
    }
  
    func fileManagerSetup(){
     let fm = FileManager.default
      let path = Bundle.main.resourcePath!
      let items = try! fm.contentsOfDirectory(atPath: path)
      for item in items {
        if item.hasPrefix("nssl"){
          pictures.append(item)
        }
      }
      print(pictures)
    }
  
    private func setupView(){
      view.addSubview(tableWithImages)
      tableWithImages.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
      tableWithImages.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
      tableWithImages.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
      tableWithImages.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
    }
  }
  
  extension ViewController: UITableViewDelegate, UITableViewDataSource {
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return pictures.count
    }
  
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath)
      cell.textLabel?.text = pictures[indexPath.row]
      return cell
    }
  
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      let detailVC = DetailViewController()
      detailVC.selectedImage = pictures[indexPath.row]
        self.navigationController?.pushViewController(detailVC, animated: true)
      print("Row tapped: \(pictures[indexPath.row])")
    }
  }
  </code></pre>
  
  <p>Second VC:</p>
  
  <pre><code>import UIKit
  
  class DetailViewController: UIViewController {
  
    var imageView: UIImageView = {
      var picture = UIImageView()
      picture.translatesAutoresizingMaskIntoConstraints = false
      return picture
    }()
  
    var selectedImage: String?
  
      override func viewDidLoad() {
          super.viewDidLoad()
        view.backgroundColor = .white
        setupView()
        if let imageToLoad = selectedImage {
          imageView.image = UIImage(named: imageToLoad)
        }
      }
  
    private func setupView(){
      view.addSubview(imageView)
      imageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
      imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
      imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
      imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
    }
  
  }
  </code></pre>