Skip to content

Instantly share code, notes, and snippets.

@pratikshabhisikar
Created February 3, 2012 18:48
Show Gist options
  • Save pratikshabhisikar/1731706 to your computer and use it in GitHub Desktop.
Save pratikshabhisikar/1731706 to your computer and use it in GitHub Desktop.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
// Check if editing style is of type delete.
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Create the delete index path.
NSArray *deleteIndexPath = [[NSArray alloc] initWithObjects:indexPath, nil];
// Delete the object from the data source array corresponding to the "indexPath". I am assuming there is only one section in the table, thus just considering indexPath.row
[myDatasourceArray deleteObjectAtIndex: indexPath.row];
// Now delete the actual cell from the table view.
[tableView deleteRowsAtIndexPaths:deleteIndexPath withRowAnimation:UITableViewRowAnimationFade];
// Release the index path.
[deleteIndexPath release];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment