Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the difference between UIViewController and UITableViewController
    primarykey
    data
    text
    <p>Sometimes I want to subclass UIViewController for some app wide customizations. Eg. something that all view controllers should perform during viewDidLoad or viewWillAppear or so. </p> <p>Naturally I subclass UIViewController and go from there and all view controllers inherit from that. But some of the controllers run tables. And there is UITableViewController designed for that purpose. </p> <p>So I subclass UITableViewController too and just do the same things there. Which does not seem to be the smartest thing in OOP terms. And there is no multiple inheritance etc.</p> <p>And as UITableViewController inherits from UIViewController ... </p> <p>Now I am asking myself why I don't just create my own table view controller that inherits from my very own view controller subclass and adds all the table stuff. But what is <strong>"all the table stuff"</strong>? </p> <ul> <li>There is the skeleton code that xcode adds to every new table view controller. Quite handy but that can be easily moved to code snippets. </li> <li>There is the declaration of the protocols UITableViewDelegate and UITableViewDataSource. Easy going. The implementation of those methods has to follow in each subclass of UITableViewController anyway. </li> <li>There are probably reasonable default implementations of all those mandatory methods in the protocol. Such as returning 0 for numberOfSectionsInTableView: or nil for titleForHeaderInSection or 44.0f for heightForRowAtIndexPath: (Bad example though. Could be smarter not implementing that at all) </li> </ul> <p>So despite the obvious stuff, are there any miracles that UITableViewController takes care of? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload