In Xcode
when I create a new view controller to contain a tableview I have two options
UITableViewController
UIViewController
that implements the UITableViewDelegate
and UITableViewDataSource
protocolsAssuming I properly implement all of the required and optional methods for the protocols, is there any advantage (besides not having to write the method stubs) to using the UITableViewController
? means, is there anything (memory management, caching, etc.) implemented behind the scenes in the UITableViewController
class that makes option 1 a better choice than option 2?
You have to write the delegate and protocol methods regardless of which of the two approaches you take.
There are only two possible reasons you should choose to use UIViewController
over UITableViewController
when you need a view controller with a table view:
UITableViewController
).Here are all of the things that UITableViewController
does for you that you would need to replicate:
UITableView
.setEditing:animated:
method to also set the editing
property of the table view.viewWillAppear:
method depending on the clearsSelectionOnViewWillAppear
property.viewDidAppear:
method.contentInset
(as of iOS 7).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With