I’m trying to setup a UITableView for displaying nested threaded items. I’m using Core Data and a NSFetchedResultsController, but am not sure what my approach should be. I want to display the information like this:
- Item #1
- Item #1.1
- Item #1.2
- Show All
- Item #2
- Item #2.1
- Item #2.2
- Show All
In the above, each sub-section has a ‘Show All’ button that when clicked will be replaced with additional subitems (each bullet above is a single table view cell). Anyone done anything similar and have any approach hints? Thanks.
I wouldn’t bother trying to cram a NSFetchedResultsController into a mode it was not created for. The FRC has no intrinsic support for nested tables and I think it would take more work to hack it to do a nested table than it would to just write a custom tableview controller to handle the problem. That is doubly true if your table will display objects from two or more entities.
Moreover, I would caution against using nested tables on a handheld mobile. The iPhone screen will only show about 11 standard sized rows. So, given your example above, you will only see two or three node headings at anyone time. Worse, if you have a node with more than 11 leaves, you will see nothing but a screen of leaves and the hierarchical nature of the tableview will be disguised.
In most circumstances, a hierarchy of tableviews, each showing on a single separate level, is almost always the best design.