I've got a button that toggles setEditing on a TTTableView. Previously I'd been using a "regular" UITableView and the following method to actually delete the data, but I don't see anything similar in the Three20 classes and using my method doesn't get called when the delete button is pressed on a row.
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
//do work}
I must be missing something but I can't figure out where. It seems like setEditing in TTTableViewController isn't connected up to anything. There's a didDeleteObject method but I've no idea whether that's supposed to be a replacement for the above method or not. Any input would be greatly appreciated.
Best Answer
Your experience with
TTTableViewController
is also going to be a little different than you might expect because it does not inherit fromUITableViewController
. Unlike most iPhone tutorials that have the table's view controller also implement theUITableViewDelegate
andUITableViewDataSource
protocols, Three20 implements them through separate classes: you are expected to set the controller'sdataSource
property with a model instance, and the controller creates its own delegate (in thecreateDelegate
method, which you can override).The method you want to implement,
tableView:commitEditingStyle:forRowAtIndexPath:
, is part of theUITableViewDataSource
protocol, so you're going to need to implement that on your model class, and not on the controller itself.The
TTTableViewController
does not directly do anything withsetEditing:animated:
, and just inherits the base implementation fromUIViewController
.The
model:didDeleteObject:
method that you see is inherited fromTTModelViewController
as an implementation of theTTModelDelegate
protocol. It's there so that changes to the underlying data model can notify the view layer of changes. For instance, if your application is downloading data from the web, rows may appear and disappear all the time, independent of what's going on with the user interface. If you're trying to drive edits through the UI, you shouldn't need to mess with that.