In my iOS app, the user progresses through the app like so:
VC1 > VC2 > VC3
I want to determine if the user presses the back button from VC3 to return to VC2 and execute some code if the user does so. I thought i would be able to do this within the didMoveToParentViewController method within VC2 and determining the previous view controller, but it isn't returning the right viewController (it's returning VC1).
What is the best way to do this?
This is what I currently have
-(void)didMoveToParentViewController:(UIViewController *)parent{
NSLog(@"returned to VC2");
NSInteger numberOfViewControllers = self.navigationController.viewControllers.count;
if(numberOfViewControllers >=2){
// returned to view -> reload projects
NSLog(@"reloading projects from VC3");
[self loadProjects:self.view];
}
}