views:

649

answers:

1

Hi all

I simply try to delete a row from a uitableview with the following code:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (editingStyle == UITableViewCellEditingStyleDelete)
     {
         [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
     }
}

The problem is that my app crashes. (GDB: Program received signal: "EXC_BAD_INSTRUCTION".) Anybody know why?

Thanks in advance.
Sean

+1  A: 

You probably need to change the number returned in

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section

for the indexPath.section to be one lower than before the deletion.

Felix
ok, i'll try this. thanks!
Sean
yep, I had to remove the object out of my array first before deleting this row. know it works! thanks
Sean