-
Notifications
You must be signed in to change notification settings - Fork 2
Tableview Delegate Methods Not Forwarded to Fallback Data Source #13
Description
Overview:
This issue outlines buggy behavior found with URBNArrayDataSourceAdapter pertaining to the fallback data source and UITableViews.
Steps to reproduce issue: (see code snippet below)
- allocate a new instance of URBNArrayDataSourceAdapter
- set the table view's dataSource and delegate to the adapter instance
- set the fallback dataSource to the containing view controller
- set the adapter's tableview property to the view controller's tableview reference
self.dataAdapter = [[URBNArrayDataSourceAdapter alloc] initWithItems:@[]];
self.tableView.dataSource = self.dataAdapter;
self.tableView.delegate = self.dataAdapter;
self.dataAdapter.fallbackDataSource = self;
self.dataAdapter.tableView = self.tableView;
Outcome:
Delegate Methods implemented in the fallbackDataSource are not called (e.g. heightForRowAtIndexPath, didSelectRowAtIndexPath)
Desired Behavior:
Messages should be forwarded up the responder chain to the fallback.
Further Analysis:
After debugging with breakpoints, I found that the following line self.tableView.dataSource = self.dataAdapter; triggers respondsToSelector to fire in URBNDataSourceAdapter at Line 247. This checks to see if the fallbackDataSource responds to the selector argument.
Since the fallback is set later on in the code block, NO is returned in this sequence. Thus, the data source adapter is sensitive to the order of operations, fallback data source should be set before the dataSource/Delegates.
I have proposed a solution via PR that corrects this issue.