iOS删除tableView行时错误

错误提示:

Invalid update: invalid number of rows in section 0

详细错误:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'Invalid update: invalid number of rows in section 6. 
The number of rows contained in an existing section after the update (0) must be equal to the number of rows contained in that section before the update (9), 
plus or minus the number of rows inserted or deleted from that section (0 inserted, 3 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

导致这个错误是因为要删除一行数据,但是呢,数据源没改动,所以一定要在删除行之前改变数据源。
PS:我出现此问题是因为,我的数据源是不可变数组,然后放到了可变数组中,操作可变数据,但是数据源还是没变,这样删除的时候就会出现这个错误。
出现这个错误,不会刷新走数据源代理,但是会检查数据源。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容