mystcolor/JTRevealSidebarDemo — Issue #1: Needed a generic solution to display dynamic table rows using same viewController
Author: mystcolor
Created: 2011-10-17 08:10:20+00:00
State: open

In most cases, we may point our UITableView datasource/delegate to the current viewController. But the problem is this split view requires single viewController model, how can we put multiple datasource clean enough to be managed by a single view controller?

There a potential solution in the branch https://github.com/mystcolor/JTRevealSidebarDemo/tree/JTTableViewDatasource, the technique behind is constructing the cell objects in a format of JTTableViewCellType* objects into a JTTableViewDatasource instance, then the mainViewController conforms to the datasourceDelegate below and dequeues correct cells layout based on that object's protocol. Do we have any better solutions?

@protocol JTTableViewDatasourceDelegate

- (void)datasource:(JTTableViewDatasource *)datasource
tableView:(UITableView *)tableView
didSelectObject:(NSObject *)object;

- (UITableViewCell *)datasource:(JTTableViewDatasource *)datasource
tableView:(UITableView *)tableView
cellForObject:(NSObject *)object;