错误集合

  • 1
Invalid update: invalid number of rows in section 1.  The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

我的代码错误原因

// roloadData中描述
You should not call this method in the middle of animation blocks where items are being inserted or deleted. Insertions and deletions automatically cause the table’s data to be updated appropriately.
   // 代码中的逻辑有可能出现下面这种情况
    NSMutableArray *indexPathList = [NSMutableArray array];
    [indexPathList addObject:[NSIndexPath indexPathForRow:2 inSection:1]];
    [self.tableView reloadData];// roloadData在插入、删除或者刷新组时调用回报错,导致和numberOfSectionsInTableView:返回不一致,造成闪退
    [self.tableView insertRowsAtIndexPaths:indexPathList withRowAnimation:UITableViewRowAnimationAutomatic];

你可能感兴趣的:(错误集合)