Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Navid Mirzaie Milani
Navid Mirzaie Milani
6,274 Points

changing the navigationcontroller title dynamically

Hi there best Collegue,

after followed some IOS tutorials on Treehouse i thought it is time to figure some things out by myself , and yes.. it's hard out there on your own :p.

Right now i've a TableViewController that gets its data from a JSON file and shows it in the tableview. What i want to achieve is when i click on an item and the detailView appears the title of the navigationcontroller must be set as same as the title of the item.

how can i manage to this? Below you can find the prepareForSegue method

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    if([segue.identifier isEqualToString:@"showClub"]){
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        NSDictionary *dic = [self.clubs objectAtIndex:indexPath.row];
        NSString *title = [dic objectForKey:@"name"];    

    }

}

I'm not looking for the simple solution (copy , paste code) i rather preferrer a explanation so i can understand it for the future.

Tnx in advanced.

Try something like this:

    self.title = [contactInfo objectForKey:@"cellName"]; 
    //contactinfo would be the dictionary or array you can put this line in the viewdidload of the detail view controller.