I’ve praised the amazingly useful NSFetchedResultsController
before, but today I want to point out a tiny little problem with this class, or at least its documentation. Briefly, objectAtIndexPath:
will sometimes return objects for invalid index paths.
Theory
The docs state that:
If indexPath does not describe a valid index path in the fetch results, an exception is raised.
This is not always true.
Practice
Sometimes (yes, it’s a heisenbug) an NSFetchedResultsController
will return a (previously removed?) object when passed an invalid index path, instead of throwing an exception. This isn’t a huge deal, unless you’re, say, populating some rows in your table from the controller, and others manually, and depending on the exception to trigger manual generation. Then it’s a problem.