Delegates and Navigation Controllers

Published on Monday, 28 November 2016

Using Delegates with Navigation Controllers

Get the nav controller first.

[gist b044059d586dd051b4c88225df1168b4]

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;
    }
}

Wordpress Original Link