title: Open New ViewController when textField is selected in tableView Swift
body: <p>I am using one textField in my tableView and getting different data by using <code>indexPath.row</code> but the problem is I am trying to open a new <code>ViewController</code> when particular textfield is selected in <code>tableView</code>.</p>
  
  <p>UITableViewCell class:</p>
  
  <pre><code>class AddCustomerCell: UITableViewCell {
  
  
  @IBOutlet weak var textfield: SkyFloatingLabelTextField!
  
  override func awakeFromNib() {
      super.awakeFromNib()
  }
  
  }
  </code></pre>
  
  <p>UITableView datasource and delegate method:-</p>
  
  <pre><code>func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
      return 3
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      guard let cell = self.tableView.dequeueReusableCell(withIdentifier: "customerCell", for: indexPath) as? AddCustomerCell else {
          return UITableViewCell()
      }
      cell.textfield.delegate = self
      cell.textfield.placeholder = fieldArr[indexPath.row]["title"]
      cell.textfield.title = fieldArr[indexPath.row]["title"]
      cell.selectionStyle = .none
  
      if indexPath.row == 0 {
  
          cell.textfield.text = self.fullName
          cell.textfield.keyboardType = .default
      }
      else if indexPath.row == 1 {
  
          cell.textfield.text = self.email
          cell.textfield.keyboardType = .emailAddress
      }
  
      else if indexPath.row == 2 {
          cell.textfield.text = self.phoneNumber
          cell.textfield.keyboardType = .numberPad
      }
      else if indexPath.row == 3 {
          cell.textfield.text = self.areaSalesMen
          cell.textfield.keyboardType = .default
      }
  
      else {
          cell.textfield.isSecureTextEntry = false
  
      }
  
      return cell
  }
  </code></pre>
  
  <p>UITableView didSelect row method</p>
  
  <pre><code>func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      let indexPath = tableView.indexPathForSelectedRow!
      print("index \(indexPath.row)")
  
      if indexPath.row == 0 {
          print("full name is selceted")
      }
      else if indexPath.row == 1 {
  
      }
      else if indexPath.row == 2 {
  
      }
      else if indexPath.row == 3 {
          let vc = AreaSalesMenListViewController.instantiate(fromAppStoryboard: .Main)
          self.navigationController?.pushViewController(vc, animated: true)
      }
  </code></pre>
  
  <p>Here is UItextField extension:-</p>
  
  <pre><code>extension AddCustomerViewController: UITextFieldDelegate {
  
  func textFieldDidEndEditing(_ textField: UITextField) {
      if let indexPath = self.tableView.indexPath(forItem: textField) {
          if indexPath.row == 0 {
              //firstName
              self.fullName = textField.text ?? ""
  
          }
          else if indexPath.row == 1 {
              //lastName
              self.email = textField.text ?? ""
  
          }
          else if indexPath.row == 2 {
              //userId
              self.phoneNumber = textField.text ?? ""
  
          }
          else if indexPath.row == 3 {
              //asm
              self.areaSalesMen = textField.text ?? ""
              let vc = AreaSalesMenListViewController.instantiate(fromAppStoryboard: .Main)
              self.navigationController?.pushViewController(vc, animated: true)
          }
  </code></pre>
  
  <p>I want to open new <code>ViewController</code> when the <code>textField</code> is selected in <code>indexPath.row == 3</code>. How can I do this. Please help?</p>