I'm writing my first splitView controller app for the iPad (and indeed my first major Xcode project), and I've run into a problem I don't understand. When the app loads, theres a list of items in the RootView, and when the user taps on one, it loads another list (a second level). I create a new RootViewController and push it into the view, and at this point, I cannot assign a property to the detailView. Here's the offending code:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detailViewController.detailItem = [self.devices objectAtIndex: indexPath.row];
NSLog(@"row: %d, detailItem: %@, source: %@, modeTags: %d",indexPath.row, detailViewController.detailItem, [self.devices objectAtIndex: indexPath.row], self.modeTags);
if (self.modeTags != 1)
{
RootViewController *nextView = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
nextView.modeTags=1;
nextView.device = [self.devices objectAtIndex: indexPath.row];
[self.navigationController pushViewController:nextView animated:YES];
[nextView release];
}
}
So, the first time through, when i click an item in the list, NSLog logs something like:
row: 3, detailItem: Item C, source: Item C, modeTags: 0
then it slides in a new view, with a new list, but clicking on an item in the new list reveals the problem:
row: 3, detailItem: (null), source: Item2 C, modeTags: 1
detailItem remains (null)!
When I trace the program, the .setDetailItem method never appears to even run, it just sort of skips it. (The first time through, it does descend into the setter and everything works as expected). I don't understand why. Can someone help me out?