2012年4月13日金曜日

invalid number of rows in section


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

UITableViewのCellを削除した直後の再描画でtableView:numberOfRowsInSection:が返す行数が直前の行数-削除した行数になっていない場合、あるいはCellを追加した場合は+追加した行数になっていない場合に発生します。

例えばNSArrayの要素とUITableViewのCellが対応しているような場合、Cellを削除したら同時にNSArrayの要素も削除しないと発生します。

0 件のコメント: