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).'

導致這個錯誤是因為要刪除一行數(shù)據(jù),但是呢,數(shù)據(jù)源沒改動,所以一定要在刪除行之前改變數(shù)據(jù)源。
PS:我出現(xiàn)此問題是因為,我的數(shù)據(jù)源是不可變數(shù)組,然后放到了可變數(shù)組中,操作可變數(shù)據(jù),但是數(shù)據(jù)源還是沒變,這樣刪除的時候就會出現(xiàn)這個錯誤。
出現(xiàn)這個錯誤,不會刷新走數(shù)據(jù)源代理,但是會檢查數(shù)據(jù)源。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容