Basic UITableView implementation

Let's start by checking out exactly how we'd create a list, similar to the one found in our ListView.swift file.

Although we can make use of Storyboards to create TableViews, for this comparison, we'll give all our examples programmatically so that we can provide a more direct comparison with the declarative syntax we've just been practicing.

Let's start by creating an instance of a TableView in an empty ViewController:

class ViewController: UIViewController {    var tableView: UITableView!        override func viewDidLoad() {        tableView = UITableView(frame: view.frame)        view.addSubview(tableView)            }}

As shown in the highlighted code, we've created the tableView variable, which we'll use throughout our class. Next, ...

Get Learn SwiftUI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.