How to delete table rows programmatically?

Posted by Donal O'Danachair on Stack Overflow See other posts from Stack Overflow or by Donal O'Danachair
Published on 2010-04-21T15:40:05Z Indexed on 2010/04/21 15:43 UTC
Read the original article Hit count: 307

Filed under:
|

I have a table which I am manipulating with a tableViewController (no nib, and the controller is creating the table behind the scenes) I'm trying to delete a row from the table based on its row number; I can delete it from the array I use to create the cell in cellForRowAtIndexPath, but I get a strange error if I try to do the following, which is the same code as in tableView:commitEditingStyle:forRowAtIndexPath: where it works fine

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i+1 inSection:1]
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]         withRowAnimation:UITableViewRowAnimationFade];

It gives an error

-[_WebSafeForwarder forwardInvocation:]

and then jumps out of the method but does not crash the app

Can anyone help?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableview