I want to build an app to navigate a data hierarchy. The structure of this hierarchy is something like the one I\'m showing in the following image. A branch of the structure
Sure, you can re-use a UITableView
. The UITableView
has 2 fundamental pieces, the UITableViewDelegate
and the UITableViewDataSource
.
UITableViewDelegate controls a lot of the table interaction and some display characteristics (heightForRowAtIndexPath
and such). What happens when you select a row. Can you even select a row?
UITableViewDataSource is the well, source of the data. How many sections does the table have? How many rows in each section? What are the content of the cell at Section X, row Y?
You could for instance, use the same UITableView
and UITableViewDelegate
for each table in your hierarchy, but change the UITableViewDataSource
. When you want to change the data source, you might do something like...
if (isSingingBand) {
self.tableview.dataSource = [TableABBADataSource alloc] init];
} else {
self.tableview.dataSource = [TableAABDataSource alloc] init];
}
[self.tableview reloadData];
Apple's programming guide on Table Views should answer a lot of questions you might run into how implementation.