How to reload the previous view controller on back button?
You have to call your API method in viewWillAppear()
. So, whenever you come back from any viewController, your updated server data will reload itself.
I assume you are sending a web call from viewDidLoad()
. So in order to update your viewController A Add your web call method in viewWillAppear()
The state of your "data" on view controller A has not changed and you need to refresh it. If you're fetching data for view controller A within -viewDidLoad
, try moving it to a different life cycle method like -viewWillAppear
.
Remember, -viewDidLoad
gets called only when the view controller loads which happens once, however -viewWillAppear
gets called before it appears which will happen often if you're hopping back and forth between views.