I want to save DB when the back button clicked in navigation controller.
so I would insert code in method.
What method is called when back button clicked in navigation controller?
I want to save DB when the back button clicked in navigation controller.
so I would insert code in method.
What method is called when back button clicked in navigation controller?
To do what you asked, look at the
UINavigationControllerDelegate
protocol, namely the method:when the viewController argument is no longer your view controller then you should save.
However, doing so on
viewWillDisappear:
might be a better (and much simpler) idea.Maybe it's not appropriate use, but that worked for me. Don't forget to set UINavaigationController delegate.