Where to put code to be run when the Back bar button is tapped in a Show Detail segue?

When the Back button on the navigation bar is tapped on a view controller that is presented as a Show Detail, the prepareForSegue callback method is not called. Is there a way to run code when the Back button is tapped? Or is there a way to hide the Back button? I can add my own buttons, but then I would need to remove the Back button item.

I understand you segue from 1 to 2, via an information button in a cell (accessory action)?


Why do you need to prepare for segue to return from 2 to 1 in that case ?

I actually segue from view controller 1 to view controller 2 via the peformSegue function.


I need to run prepareForSegue so that I can write whatever the user chooses in view controller 2 to UserDefaults so that I can retrieve values from UserDefaults to initialize variables when view controller 2 is run next time.

Where to put code to be run when the Back bar button is tapped in a Show Detail segue?
 
 
Q