I've the following class scheme implemented in obj-c: class A is a subclass of UIViewController. Classes B and C are subclasses of A. Now I need to create a class D that has to be a subclass of A, but it contains a UItableView so it would need UITableViewController functionality too. My question is, how do I solve this problem? Whats the most elegant way of doing this? I've some ideas on how to do it:
1- Make A a subclass of UITableViewController and overload the loadView method on the classes that dont use UItableViews to catch the exeption thrown when se try to load a UITableViewController without a UITableView. (This solution seems to me more like an hack than a solution!)
2- Keep everything unchanged and implement the UITableDelegate and UITableDataSource protocols in D. (This solution seems to me more elegant than the first one but I'm clearly reemplementing UITableViewController).
3- create a UItableViewController inside class D to manage the tableView on behalf of D.
4- Make D a subclass of UITableViewcontroller instead of A and create a data member of type A inside D to manage the A part of D's job.
What do you think is the best way to do it? Transforming A into a protocol is not an option.
Thank you.