I'm using the Big Nerd Ranch BNRCoreDataStack
, but I suspect that this problem would exist if I was using standard CoreData
.
I have a FetchedResultsController
to populate my table by fetching NSManagedObjects. These are being rendered in sections and rows. My problem is that when I delete my NSManagedObjects
elsewhere, I get an error from the FetchedResultsController
:
[error] error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to insert row 0 into section 1, but there are only 1 sections after the update with userInfo (null)
This leaves my cells visible in the table afterwards, and when I tap on one I get this error:
fatal error: Index out of range
So, this tells me that the FetchedResultsController
has failed to remove the cells from my table when I deleted the CoreData objects.
What is strange is that I am reloading the table data on viewWillAppear
so I would assume that that would clear the table. How can I force the FetchedResultsController
to dump all knowledge of the data and start from scratch?