Sometimes Xcode will show an error "Expected expression" on the line after a case. For example, Xcode is pointing to UserContentViewController with a red arrow:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case IndexVideo:
UserContentViewController* detailViewController = [[UserContentViewController alloc] initWithUser:self.user];
[self.navigationController pushViewController:detailViewController animated:YES];
break;
}
}
If I put braces around my case, the error is gone. Firstly, I want to know what is the problem with not using braces. I've never used braces in cases in any other language. Secondly, why does Xcode only complain about my cases on rare occasions? I can't quite discern what type of code triggers this error.