There is a textfield , enter image description here which is inherited from the ViewHelper.designForInputText(textField: Region) class ViewHelper.designForInputText(textField: Region) , I made it so that when I clicked on it, it leads to another viewcotroller - Regions

 @IBAction func RegionClick(_ sender: Any) { Region.inputView = UIView() let newViewController = Regions() self.navigationController?.pushViewController(newViewController, animated: true) } 

It all works, and when some operations are completed (in this case, the previous Registration controller returns when choosing any position, so as not to complicate things),

 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if tableView == self.tableView{ let newViewController = Registration() self.navigationController?.pushViewController(newViewController, animated: true) }else{ let newViewController = Registration() self.navigationController?.pushViewController(newViewController, animated: true) } 

already when it passed back, it gives an error Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

enter image description here

If you make a check for nil, then exactly the same thing happens with the next variable Phone , what's the error with this return?

    1 answer 1

    In general, the return is uinavigationcontroller.popviewcontroller(animated:) . Push is the creation of a new controller and the transition to it. And I did not understand why use textField instead of a button. If you click on an object opens another controller, this is the work of UIButton.

    • Yes, thanks, it works. but at the expense of the textfield, then the selected object will be returned to it from Json later, aesthetically more pleasant when it is all the same - Romik romikromik
    • You can make the same design for UIButton and UITextField and UILabel. - FreeGor