[A] -> Show Segue -> [B]
Everything is inside a navigation controller. When the user pushes the back button on "B", how can it know? I want to perform an action (save profile) immediately when the user pushes back.
The UIViewController class has a function called willMoveToParentViewController. I would try using that to accomplish what you're trying to accomplish.
override func willMoveToParentViewController(parent: UIViewController?) {
print("back button was pressed")
saveMyProfile()
}
Something like that should hopefully do the trick.