views:

62

answers:

1

Hey, I have a tableview which content is managed through core data. When I select a row, a details view is pushed in and shows more information. How can I jump to the next record (the one below the one I selected in the tableview before) through a "next" button in the view ? Same for a previous button, but that should be very similar ...

thx a lot ! Sebastian

ps: One more question ... how do I get a random record from my fetchedResultsController ?

A: 

The "next" record changes depending on the sort you applied to the fetch that returned the data for the table. In order to reproduce the order of the table, you need to reproduce the fetch.

In your detail view, you will need a fetch with the same entity and sort descriptor used to generate the table view. You will need to track the index of the current record being displayed in the detail view. Then going to the next or previous record is just a matter of going to the next or previous element in the array returned by fetch.

If this is a major part of your app, you might want to build the order into your data model by having the entities relate to each other with a "next" and "previous" relationship. That turns them into a linked list which is easy to traverse.

TechZen