I have (at least) two views which have the same table view but other stuff around, depending on how the user navigated in the app. Ideally, I would like to have a generic table view and controller which other views and controllers could, for lack of a better term, "include". This would then allow me to encapsulate all the table view and controller logic within one file, so I don't have to duplicate code and logic between different views. Hopefully this question makes sense. How do achieve this?
+1
A:
Create a UITableViewController subclass, and stick all of your table datasource and delegate methods in there. ( Of course conforming to UITableViewDelegate protocol )
Declare it as a singleton, and then assign it as an ivar to each of your other view objects.
From there, you can share a managed tableview object.
I hope this helps.
Jacob Relkin
2009-11-30 03:14:45
This could lead to all kinds of issues since a UIView can only have one superview.
Ed Marty
2009-11-30 04:55:52
So.. What do you suggest, Ed? How can this be done? How do I have two similar views without code duplication?
tbehunin
2009-12-01 03:56:39