In my app i have reset button which delete all the data of tables and database.but before deleting i have to put alert view and ask the question as follows:
- (IBAction)resetData:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Bills Data Entry"
message:@"Are you sure want to reset data?" delegate:nil
cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
[self databaseOpen];
NSString *deleteData=[NSString stringWithFormat:@"delete from tbl_Bills"];
[database executeQuery:deleteData];
NSLog(@"inert query: %@",deleteData);
NSLog(@"records deleted");
[table reloadData];
[database close];
// DO STUFF
}
}
This method is not called when i click on yes.
UIAlertView’s delegate must not be nil if you want to invoke its delegate method.