Using Delegates with Navigation Controllers
Get the nav controller first.
[gist b044059d586dd051b4c88225df1168b4]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
if ([segue.identifier isEqualToString:@"showLocations"]) { | |
//LocationsTableViewController *ltvc = (LocationsTableViewController *)[segue destinationViewController]; | |
UINavigationController *navController = [segue destinationViewController]; | |
LocationsTableViewController *ltvc = (LocationsTableViewController *)([navController viewControllers][0]); | |
ltvc.delegate = self; | |
} | |
} |
Controller.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showLocations"]) {
//LocationsTableViewController *ltvc = (LocationsTableViewController *)[segue destinationViewController];
UINavigationController *navController = [segue destinationViewController];
LocationsTableViewController *ltvc = (LocationsTableViewController *)([navController viewControllers][0]);
ltvc.delegate = self;
}
}