How To Add Alert When You Delete A Cell Row?

Joined
Oct 11, 2011
Messages
46
Reaction score
0
Points
6
Your Mac's Specs
13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
How can i add an alert when i delete a cell row? i know how to make an alert, i just don't know how or where to put it in the the method:



Code:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    GlobalStrings* theDataObject = [self theGlobalClass];
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [theDataObject.prodTableArray removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}


ill be thankful for any help/advice
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
I suspect in the method you listed. If you want the alert after the deletion, then try placing it at the end. If you want to warn of a deletion, I have to wonder why you think the user didn't mean the action they just took. Still, I think you'd save all of the passed parameters, set a flag that you're waiting for a response, post the alert and skip the deletion code. If the response to the is OK, then change the flag, and recall this method with the parameters you saved.

Hopefully this quick thought is helpful.
 
OP
L
Joined
Oct 11, 2011
Messages
46
Reaction score
0
Points
6
Your Mac's Specs
13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
I suspect in the method you listed. If you want the alert after the deletion, then try placing it at the end. If you want to warn of a deletion, I have to wonder why you think the user didn't mean the action they just took. Still, I think you'd save all of the passed parameters, set a flag that you're waiting for a response, post the alert and skip the deletion code. If the response to the is OK, then change the flag, and recall this method with the parameters you saved.

Hopefully this quick thought is helpful.

thank you for your help,


i wanted an alert so that the the user chooses why he deleting it, like over priced, clerk error, void (they didn't want it anymore), or cancel just for face.
 
Joined
Mar 9, 2012
Messages
3
Reaction score
0
Points
1
try to use the given code before your code perform the delete statement. you may add in other feature in otherButton Titles. to perform optional choice.

UIAlertView *alertmsg=[[UIAlertView alloc]initWithTitle:mad:"Alert Message" message:mad:"Data going to be remove" delegate:nil cancelButtonTitle:mad:"Close" otherButtonTitles:nil];

[alertmsg show];
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top