Search code examples
iphoneobjective-cdetailsview

How do I set a detail view's title from the selected row?


I have a table view made up of an NSArray of instances of a custom object. When a row in the table view is tapped, it is supposed to trigger a detail view made up of a web view.

So, in MainViewController.m, I have the following:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MObjectDetailVC *mObjectDetailViewController = [[MObjectDetailVC alloc] initWithNibName:@"MObjectDetailVC" bundle:nil];
mObjectDetailViewController.detailURL=[[[mcData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] object.url]];
mObjectDetailViewController.title=[[[mcData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] object.name]];

[self.navigationController pushViewController:mObjectDetailViewController animated:YES];
[mObjectDetailViewController release];
}

However, I get an error for both that start with mObjectDetailViewController: Expected ']' before '.' token. and I don't know why. Can you help? Thanks!

UPDATE: I reduced the amount of square brackets, but I still have the error on each of those lines. It's just that instead of 3 of that error on each line, there's just one instance for each.


Solution

  • At the end of the lines that were giving me issue, I called object.url and object.name. This was unnecessary and invalid. I just needed to put url and name to get those variables from my selected object.

    Thanks for your help!