Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 10: Exception when changing Make #1

Open
mauricesharp opened this issue Dec 20, 2013 · 0 comments
Open

Chapter 10: Exception when changing Make #1

mauricesharp opened this issue Dec 20, 2013 · 0 comments
Assignees

Comments

@mauricesharp
Copy link
Owner

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!

@ghost ghost assigned mauricesharp Dec 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant