I have a UIAlertView with buttons and I am trying to make these buttons execute an action. The problem is I have an “undeclared identifier” in my method.
THE ISSUE I SEE http://tinypic.com/view.php?pic=28qvhom&s=6
THE CODE
The alert view
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Well done!"
message: @"You got all 20 in Time: x"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"Save and Quit", @"Quit", nil];
[alert show];}
the void
-(void)alertView:(UIAlertView* )alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==0) {/*some action */ }
else if(butonIndex==1){/*some action */}
}
//I aso have <UIAlertViewDelegate> in my .h file.
The problem is in
else if(butonIndex==1)you’re missing the second “t” in the word button.For future reference, Xcode’s “Fix-It” feature will fix trivial mistakes like this for you.
Click the red circle to activate the fix-it menu then simply hit enter.
EDIT:
Do this:
Not this:
If this isn’t the case, then you are missing a closing brace “}” at the end of the method before the alert view delegate.