How to delete row in TTTableViewController (Three20)
Posted
by Dmitry
on Stack Overflow
See other posts from Stack Overflow
or by Dmitry
Published on 2009-12-06T13:53:39Z
Indexed on
2010/03/08
13:36 UTC
Read the original article
Hit count: 1042
Hi,
The Three20 is great library. It's making the work with tables very easy. But one gap that I noticed - is deletion of rows, with animation. I spent many hours trying to do this, and this is what I'm doing:
// get current index patch
UITableView* table = [super tableView];
NSIndexPath *indexPath = [table indexPathForSelectedRow];
//delete row in data source
TTListDataSource * source = (TTListDataSource *)self.dataSource;
[source.items removeObjectAtIndex:indexPath.row];
// delete row from the table, with animation
[table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
After this code runs the error appears: [NSCFArray objectAtIndex:]: index (0) beyond bounds (0)
I'm using the class inherited from the TTTableViewController. And I doesn't implement the DataSourceDelegate or TableViewDelegate because I'm using the Three20 as much as possible. So, this is how I create datasource:
for(NSDictionary *album in (NSArray *)albums){
TTTableRightImageItem *item = [TTTableRightImageItem itemWithText:@"name"
imageURL:@"image url"
defaultImage:nil
imageStyle:TTSTYLE(rounded)
URL:@"url of selector where I actually catch the tap on a row"];
[tableItems addObject:item];
}
self.dataSource = [TTListDataSource dataSourceWithItems:tableItems];
I read this article (article) but it doesn't help :(
So, I know that this is very simple for gurus from this site. Can you just give me advanced sample of how to do this
Thanks
© Stack Overflow or respective owner