I have a problem with alerts. When I’m adding following to my program it shows error:
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"That's it" message:@"THANKS FOR USING" delegate:self cancelButtonTitle:@"bye" otherButtonTitles:nil];
[alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"Button %d pressed", buttonIndex);
[ alertView release ];
}
This shows errors—-alertView undeclared and expected ; before:
Please help me solve my problem. I want to perform some actions when I click the button on an alert.
In which line are you getting the error and what is the exact error? Have you added the UIAlertViewDelegate protocol in the interface declaration? It seems that you have not.
And you don’t need to release alertView in delegate method. You can just release it after showing.