我使用PFQueryTableViewController与本地数据存储。我想使用户从表中删除对象与此代码:iOS - PFQueryTableViewController - 删除行崩溃
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
PFObject * object = [self.objects objectAtIndex: indexPath.row];
[object deleteInBackgroundWithBlock:^(BOOL succeeded, NSError * error) {
[self loadObjects];
}];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
我得到这个 ***终止应用程序由于未捕获的异常“NSInternalInconsistencyException”,理由是:“无效的更新:行数无效在部分0.更新(2)后现有部分中包含的行数必须等于更新前(2)部分中包含的行数,加上或减去从该部分插入或删除的行数部分(0插入,1删除)以及正数或负数移入或移出该部分的行数(移入0,移出0)。'
我想,这是一个PFQueryTableViewController中使用的注释,但我找不到解决方案。 非常感谢。
谢谢你的回答。有了这段代码,我得到了其他错误:***声明失败 - [UITableView _endCellAnimationsWithContext:],/SourceCache/UIKit_Sim/UIKit-3347.44.2/UITableView.m:1623我正在调查这个错误的含义。你有什么主意吗。 –
最后我在这里找到了解决方案:http://stackoverflow.com/questions/31358082/when-delete-cell-and-self-loadobjects-in-pfquerytableviewcontroller-it-gets-a –
哦拍。对不起,我的意思是改变这一点,但有其他问题跟踪并忘记回来。抱歉。这个错误是给定的 – soulshined