“Invalid update: invalid number of sections. The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (0), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted). Table view: <UITableView: 0x7ff64900a000; frame = (0 0; 390 844); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000a7f090>; layer = <CALayer: 0x60000047cea0>; contentOffset: {0, -143}; contentSize: {390, 0}; adjustedContentInset: {143, 0, 34, 0}; dataSource: <Todos.TodosVC: 0x7ff644706850>>”
出现原因:数据发生改变后 tableView 没有更新
解决方法:
在修改的数据后面加上
tableView.reloadData()