如何基于NSDictionary数据模式从UITableView节中删除行和节?
下面提到的代码用于删除特定行如何基于NSDictionary数据模式从UITableView节中删除行和节?,uitableview,Uitableview,下面提到的代码用于删除特定行 - (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row f
- (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
// You need to remove
NSDictionary *contact = [[self.sections valueForKey:[[[self.sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
NSLog(@"contact %@",contact);
[self.sections removeObjectForKey:contact];
NSLog(@"%@",self.sections);
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
// crashing at above line of code and shows error message see at the bottom of the post
}
}
通过以上代码,我可以正确加载UITableview,但我的应用程序崩溃了
当我试图从CommittedItingStyle:method中删除时?
错误消息:
2013-05-13 15:13:33.353索引表视图最终[1372:207]断言在-[UITableView\u endCellAnimationsWithContext:],/SourceCache/UIKit\u Sim/UIKit-1912.3/UITableView.m:1046您能调试并显示代码在哪一点崩溃吗@艾哈迈兹。我在问题中添加了崩溃点和错误消息您是否正在删除tableview中唯一的单元格/行?我正在使用Swipe删除CommittedItingStyle附带的功能-我已在每个部分中加载了5行tableview,我正在尝试随机删除它。您可以发布numberOfRowsAtIndexPath方法吗。。