We're having a generic swift class that acts as a UITableView data source and delegate. Not all of the methods of the UITableViewDelegate are implemented in this generic swift class. We're now trying to create a subclass of our generic swift class that implements a few extra UITableViewDelegate methods. Those, are, however not visible in Obj-C:
class DataSource<T>: NSObject, UITableViewDelegate {
let items = Array<T>()
}
class SubClassDataSource<T>: DataSource<T> {
@objc func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {return 44}
}
let dataSource = SubClassDataSource<Int>()
print(dataSource.responds(to: #selector(UITableViewDelegate.tableView(_:heightForRowAt:)))) // prints false
I would expect true
to be printed here, since the method is marked as obj-c explicitly. Is there a rational for this? How would I make this work?
(The reason we have this set up is for performance: overriding -tableView: heightForRowAt:
for very large tableviews is slow, so we rather do it in a specific subclass to not incur the performance penalty)