Question

I have been watching a lot of tutorials on Table Views, table view cells etc. When creating a table view why choose a UIViewController over a UITableViewController in Xcode? For instance what would be the main benefits of creating a UIViewController and then adding a tableView object, over just creating a UITableViewController? I have already created a large numbers of scenes within storyboard and I hope I haven't limited myself in doing so. I hope my question is clear as I am new to coding!

Was it helpful?

Solution

UIViewController gives you more control over tableview rather than UITableViewController. You should use UITableViewController only when you are just concerned with tableview in a controller. But if you want to add more subviews/controls in a controller other than tableview, then you have to use UIViewController.

EXAMPLE:

If you just want to display grocery items list with some header and footer, then tableviewcontroller should be priority. But if you want to display mail items in tableview, you would need some additional buttons for altering items in mail(tableview). For later case, you will use viewcontroller. Hope my point is clear.

OTHER TIPS

I think the benefits of having a View Controller is just more versatility and you will have a easier time to add other views other than the UItableview. Whereas UITableViewController i just inheriting a UIViewController, but with the delegates already set up for you. Basically it is assuming you will have a UITableView for sure. In the end it shouldn't really limit you, just cause you used UITableViewController, since everything you want to do in UIViewController, you can do in UIViewController.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top