0

I'm getting this error message which I can't figure out what to do or how to debug:

'Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (7) must be equal to the number of rows contained in that section before the update (7), 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).'

I have 3 sections in my table. Here's the number of rows in each section before anything changes to my data source happens:

// Check current data source
date source for section 0: 1 items
data source for section 1: 8 items
data source for section 2: 8 items

sections count: 3
section 0 1 rows
section 1 8 rows
section 2 8 rows

Here are what prints out after I delete a row from section 1 and I want to move it to section 2:

// Updated my date source
date source for section 0: 1 items
data source for section 1: 7 items
data source for section 2: 9 items

sections count: 3
section 0 1 rows
section 1 7 rows
section 2 9 rows

// Then the crash message happen

Please help. Thanks.

7ball
  • 2,183
  • 4
  • 26
  • 61

1 Answers1

2

You need to remove the object from your data array before you call deleteRowsAtIndexPaths:withRowAnimation.

Basically the same question in stackoverflow

Andy Darwin
  • 478
  • 5
  • 19