Member-only story

Cleaner UITableViewControllers

Don’t make the code more difficult than it needs to be

Steven Curtis
4 min readApr 21, 2020

When Xcode generates a default UITableViewController, and it encourages everything to go into this single view controller. This can mean a large class that is difficult to maintain, and yet this is how production code is often shipped.

It is possible to separate out the dataSource from the view controller, and should be considered as an approach if the controller starts to get too large.

Prerequisites:

Creating view controllers Delegate pattern

A standard table view displays a list of items.

All of the following are presented on GitHub

Standard table view

You can simply add a TableViewController

and it is essential for us to add the cell identifier. I call this “cell” for this example.

Setting up the view controller as a UITableViewController

--

--

No responses yet