2015-09-23

Got NSInternalInconsistencyException? Decrement data source's row numbers before deleteRowsAtIndexPaths call.



I got an interesting error message about NSInternalInconsistencyException.

The number of rows contained in an existing section after the update (746) must be equal to the number of rows contained in that section before the update (746)

Let me brief this sentence, it says "The number 746 must be equal to the number 746".

Wow, I didn't know 767 and 767 are not same number.

...

Yes, I know I should inspect my code closely AS THEY SAID.

In my case, of course it was my fault. The reason for this Exception is that I didn't refresh data source's row numbers before deleteRowsAtIndexPaths call.

P/S Here's the whole error log from my app.

2015-09-23 23:13:57.320 NewsPlayer[80774:8236299] *** 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 (746) must be equal to the number of rows contained in that section before the update (746), 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).'

Author: @ymkjp