Simple problem… I had some comments on my code and deleted them and got an error. After some hours I arrived at the source.
This code works:
switch (indexPath.row) {
case 0:
NSLog(@"case 0");
break;
case 1: // Clients
NSLog(@"case 1");
ViewClientListTableController *viewListTableController = [[ViewClientListTableController alloc] init];//]WithNibName:@"BrowseViewController" bundle:nil];
viewListTableController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:viewListTableController animated:YES];
//[self.navigationController setNavigationBarHidden:NO];
[viewListTableController release];
break;
}
This next one, (by just removing the NSLog(@”case 1″); ) does NOT work:
switch (indexPath.row) {
case 0:
NSLog(@"case 0");
break;
case 1: // Clients
ViewClientListTableController *viewListTableController = [[ViewClientListTableController alloc] init];//]WithNibName:@"BrowseViewController" bundle:nil];
viewListTableController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:viewListTableController animated:YES];
//[self.navigationController setNavigationBarHidden:NO];
[viewListTableController release];
break;
}
As you can see, only the NSLog line is gone. And the compiler is giving me 2 errors:
RootViewController.m:212: error: expected expression before ‘ViewClientListTableController’
RootViewController.m:213: error: ‘viewListTableController’ undeclared (first use in this function)
Of course, one answer is to leave the NSLog line, but really… why is this error happening?
switch statements often have trouble with variables being declared in their case labels. I bet
works in case 1: – the NSLog macro probably has an expansion that has a similar effect.