-3

In the action sheet delegate method im modaling to another view based on the button index, this is the method:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0) {
        NSLog(@"first button was pressed");
    } else if (buttonIndex == 1) {
        MyViewController *myViewController = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
        UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:myViewController];
        [self.navigationController presentViewController:navigationController animated:YES completion:nil];
    }
}

im getting the error next to the nevigationConroller declaration, does someone knows what is the problem?

im declaring MyViewController in the .h class of this class..

thanks

nick shmick
  • 905
  • 1
  • 9
  • 25
  • 1
    Search on the error. This has been covered many times. Start by looking at the Related questions to the right. – rmaddy Feb 12 '15 at 16:46

1 Answers1

1

The class that contains your actionSheet:clickedButtonAtIndex: method has an ivar named myViewController. You have created a local variable also named myViewController. Your Xcode project has been told to treat this as an error instead of just a warning. Change your local variable name.

MyViewController *myVC = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:myVC];
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
Ian MacDonald
  • 13,472
  • 2
  • 30
  • 51