I have two view controllers. One contains a menu, and the other contains a submenu. If the user taps the "back" button on the submenu's controller, then the controller needs to pass data back to the original menu.
Since both view controllers are linked to a navigation controller, I'm thinking of doing something like this:
Since both view controllers are linked to a navigation controller, I'm thinking of doing something like this:
Code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UINavigationController *navController = [self navigationController];
NSArray *viewControllers = [navController viewControllers];
NSInteger destVCIndex = [viewControllers indexOfObject:[segue destinationViewController]];
NSInteger selfIndex = [viewControllers indexOfObject:self];
if (destVCIndex == selfIndex - 2)
{
// Destination view controller was loaded before this one.
}
}