We have 2 controllers: MainVC and ProfileVC. From MainVC we go to ProfileVC with profileButton press (left item on navigation bar).
profileButton
In Profile VC we hav
To prevent this exception. Simply just dismiss the currently showed ViewController to go back to the caller of the ViewController that you are dismissing:
self.dismiss(animated: true, completion: nil)