setdirection/ios-shared — pull request #69 by rcancro (2014-03-08 05:06:31+00:00)
Title: Update SDTableViewSectionController to handle a crash in UITableView

Steve and I discovered that there is a bug in UITableView that can lead to a crash if yo do the following:

1. Implement a UIViewController with a tableView
2. Implement two NSObjects conforming to UITableVIewDataSource and UITableViewDeleegate
3. First one implements tableView:estimatedHeightForRowAtIndexPath: for section index 1 (out of 3)
4. Second one does not implement tableView:estimatedHeightForRowAtIndexPath:, only has two sections
5. Set the tableView delegate/datasource to the first delegate
6. reloadTable
7. set dataSource/delegate to delegate two
8. reloadTable
9. crash

To avoid this, we tell UITableView that we always implement estimatedHeightForRow. We then either return the section's estimatedRowHeight or, if the section doesn't actually implement the method but UITableView is confused, we return the default UITableViewAutomaticDimension (per the docs).

I kept the test for estimatedHeight in the respondsToSelector override so when the bug is fixed it will be there. If you think it should not still be there feel free to tell me so and I'll remove it.