views:

100

answers:

3

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?

A: 

Well you are missing a semi-colon on your first line.

When in doubt, clean up your syntax...

As a point of observation, most of the programmers I have worked with and talked to really hate UITableViewController. It really adds nothing to the functionality for the user and only obfuscates things that developers might really like to control... such as the position of the table via a XIB.

It's just a convenience class and in my experience, causes more issues than it prevents.

Jasconius
Donal O'Danachair
A: 

You need to do that in this block.

[self.tableView beginUpdates];

///

[self.tableView endUpdates];

do notice one thing that when the the block reaches its end

- (void) numberOfRowsInSection:(NSInteger)section

will be called again. so u need to update the number of rows in table view also.

Hope this helps.

Thanks,

Madhup

Madhup
A: 

Thanks to everyone who replied. I have to agree with Jasconius about UITableViewController. I rebuilt using UIViewController and an xib file and eventually got it working.

Donal O' Danachair