-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Hello Maurice,
I found a bug in sample code for the chapter 10.
It happens rarely but anyway it happens.
To reproduce it you need to have at least 2 section for the car make (it could be also model or year) and in one of these sections you should have at least 2 records.
The sort order should be “Make”. Then you need to change the last record of these 2 and change the name of Make - it will lead to exception and crash when you return back to Table View.
Th reason is the TableView is updated 2 times.
First during the call "controller:(NSFetchedResultsController *)controller didChangeObject: ….” with type NSFetchedResultsChangeMove - because the record is moved from one section to another one.
And the second call from “carViewDone:” where "[self.tableView reloadRowsAtIndexPaths …." leads to exception because this row was already removed by "controller:(NSFetchedResultsController *)controller didChangeObject: ….”
My suggestion to remove call of “carViewDone:” at all and just implement the case for NSFetchedResultsChangeUpdate
case NSFetchedResultsChangeUpdate:
[self.tableView reloadRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
break;
Sorry for my English, but hope this helps to improve your book.
Thanks a lot for your work!