views:

309

answers:

2

I have a tableview populated from a plist and I want to display a detail UIView for a selected row. I don't know how to pass the selected row to the detail view controller. Perhaps someone could advise the best way to do this. The table consist of technical terms and I want to show its definition when a row is selected. Thanks in advance.

+1  A: 

One solution would be to create a model class representing the elements you're displaying in the table. The first table would display the term for each of the model objects. When the user selects a row, you create an instance of your detail view controller (which will have a member of the type of the model) and set the model member. Then push the detail view controller.

So in a nutshell. Have a class that models your data and use that in both of the tables.

lyonanderson
A: 

implement the didSelectRowAtIndexPath delegate method

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

DetailsViewController *detailsViewController = [[DetailsViewController alloc] initWithNibName:@"Details" bundle:nil];

detailsViewController.book = [books objectAtIndex:indexPath.row];

[self.navigationController pushViewController:detailsViewController animated:YES];

[detailsViewController release];

}

Laureano