I have a main UITableView Controller that is backed by a NSFetchedResultsController, this view shows a list of results sectioned by time of day. This view is governed by a segmented control that determines the categories and various flags for the predicate on the NSFetchedResultsController. Everything seems good so far.
But I have a problem with the detailed view:
I want the user to be able to navigate next and previous in the detailed view much like the default ios Email app.
How would I achieve something like that with my setup? I don’t think I can just pass the entity to my detail view and increment/decrement an id, since the previous list view depends on some filter predicates.
Do I need to create in the detailed controller another nsfetchedresults controller using similar predicate? How would I effiencetly detect whether there is no more after/before the current result so I can grey out the prev/next button?
Can I somehow make use of the result set already returned by the main list view (backed with the nsfc) even though it’s batched and sectioned?
Thanks for any help to wrap my brain around this.
My first thought is to subclass
NSFetchedResultsControllerso that it remembers the index path of the most recent item that has been selected for detailed viewing. It could implement methods such as(id)nextObject,(BOOL)nextExists, and similar ones for ‘previous’.If you pass a reference to it from your table view controller into the detail controller, you could do the back and forth thing there and also sync the selected entry in your table when you return by using the current detail index path to select a cell.
The only real trick would be index path arithmetic but that should be doable by examining the
sectionsarray inNSFetchedResultsController.