2013-03-19 35 views
0

断点位于[self.tableView ...]行。滑动删除单元格时的断言失败错误

这是我第一次遇到这样的错误。我搞乱了一个实现轻扫删除功能的cocoapod。

- (void)swipeTableViewCell:(MCSwipeTableViewCell *)cell didTriggerState:(MCSwipeTableViewCellState)state withMode:(MCSwipeTableViewCellMode)mode 
{ 
    NSLog(@"IndexPath : %@ - MCSwipeTableViewCellState : %d - MCSwipeTableViewCellMode : %d", [self.tableView indexPathForCell:cell], state, mode); 

    if (mode == MCSwipeTableViewCellModeExit) 
    { 

     // Remove the item in your data array and then remove it with the following method 
     [self.tableView deleteRowsAtIndexPaths:@[[self.tableView indexPathForCell:cell]] withRowAnimation:UITableViewRowAnimationFade]; 


    } 
} 

另外,假设有一种方法可以解决这个问题,是否有可能从我的分析后端删除对象?最初我使用:

PFObject *object = [self.objects objectAtIndex:indexPath.row]; 
     [object deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { 
      [self loadObjects]; 

感谢您的帮助。

回答

1

声明失败只能通过到的NSAssert功能之一的显式调用引起的。这些用来测试开发者做出的某些假设是否属实。他们“断言”这些假设的真相,并且如果他们不真实,就会抛出异常。

据我所知,在任何Apple开发者库中都没有断言。这意味着要么你已经把断言放入你的代码中,或者更可能 - 你正在使用的cocoapod的代码中有一个。获取源代码并对“NSAssert”进行全局搜索,以了解发生了什么。

0

通常从tableView中删除项目时,首先需要修改底层数据。换句话说,如果您从数组中绘制表格,请首先从数组中删除该行,然后从表格中删除该行。

如果不工作,你可以尝试:

[mytableView beginUpdates]; 

//do my changes 

[mytableView endUpdates]; 
+0

嗯。仍然抛出相同的断言,但现在到[self.tableView endUpdates]; – STANGMMX 2013-03-19 01:41:59

相关问题