First we access the array of all view controllers and count it. We subtract one (because arrays are 0 based), and another one to go back in history – hence we go “minus 2”. Then we pop to view controller just behind the current one.

Test if the returned value is less than zero though…

If you want to go back all the way to the root view controller, there’s a method for that: