我这样定义一个成员:
@property (nonatomic, retain) NSIndexPath *deletingIndexPath; //记录当前需要删除的行
并将其分配给
- (void)tableView:(UITableView *)atableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
...
deletingIndexPath = indexPath;
...
}
并在另一个回调函数中使用它
NSArray *deleteIndexPaths = [NSArray arrayWithObjects:deletingIndexPath,nil];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
而且它崩溃了...
在模拟器中它说
2012-07-10 16:56:54.887 p[20972:16a03] *** Assertion failure in -[NSIndexPath row], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableViewSupport.m:2606
2012-07-10 16:56:54.898 p[20972:16a03] Uncaught exception: Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row. Please use the category on NSIndexPath in UITableView.h if possible.
谁能告诉我为什么?