0

I ran into strange issue

case 5:
        if(1==2) {NSLog(@"Here is a tmp stuff");}
        AuthenticationViewController *authVC = [[AuthenticationViewController alloc] initWithNibName:@"AuthenticationViewController" bundle:[NSBundle mainBundle]];
        [authVC setTitle:@"Authentication"];
            //self.authViewController = authVC;
            //[authVC release];

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

        break;

If i remove the useless if statement it fails to compile. I m unable to understand why?

tipycalFlow
  • 7,594
  • 4
  • 34
  • 45
Maanas Royy
  • 1,522
  • 1
  • 17
  • 30
  • the AuthenticationViewController is created and pushed, right? – tipycalFlow Aug 03 '11 at 04:46
  • Yes, afarnham has answered correctly. The case statement are bunch of labels are compiler is not aware of the scope. Wrapping every thing inside { } define the scope and it works – Maanas Royy Aug 05 '11 at 04:06

1 Answers1

0

You are declaring a variable in your case statement, which is illegal in C.

See the following for more info and how to solve this issue: Why can't variables be declared in a switch statement?

Community
  • 1
  • 1
Aaron
  • 2,403
  • 1
  • 24
  • 25