I have only 1 tableView class but 4 cell class. I’m adding the same tableView to all the viewControllers present in the app. The difference is the type (class,to be precise) of the cell. I want to change the class of cell according to the viewController in which the tableView is present. Also, the cell’s content view is drawn in another subclass of the cell’s class. Please provide a solution or approach to follow to make this functionality.
Thanks, in advance.
I have only 1 tableView class but 4 cell class. I’m adding the same
Share
You probably should be using a different table view for each view controller (if you are not already).
Typically, you would also use a different datasource/delegate for each table view (you could use each view controller, for example).
However, if you must use the same class as the datasource/delegate for all four of the table views,
tableView:cellForRowAtIndexPath:(and the other delegate methods) give you the table view as the first argument, so you can return the correct cells like this: