0
votes

I have a core data set of objects that I'm putting into table cells. However, I also have another set of 'spacer' cells that go in between each table cell. So when I return NumberOfRowsInIndexPath, I return the fetched results count * 2. However, when I delete cell, I get this error:

Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (15) must be equal to the number of rows contained in that section before the update (17), 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). with userInfo (null)

Is there any way I can tell XCode to ignore this error? I've read in other places that this is a potential bug. At any rate, I've review my NSFetchedResultsController delegate and I'm certain the code is correct.

1
Did you implement -controllerDidChangeContent: properly? It is difficult to advise without watching code in this method. Would you share code in this method for better understanding? - Shamim Hossain
What did you tried so far? Where’s the code itself? I think it’s not a bug as you said. - Mannopson
You need to show your code as the others have said, but essentially your problem is that you are only deleting one row from the table but the value returned from numberOfRowsInSection indicates that you have removed 2. You need to delete the associated 'spacer' cell as well. - Paulw11

1 Answers

0
votes

You are making life hard for yourself by using these spacer cells, it will be very complex to keep this in all sync as rows are added, removed and moved around.

You should redesign your UI to not require the spacer cells by putting empty space at the bottom of the actual cells, or maybe use UICollectionView instead if that doesn't sound feasible.