O'Reilly logo

Mastering iOS 11 Programming - Second Edition by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conforming to the UITableViewDataSource and UITableViewDelegate protocol

In order to specify the UITableView's delegate and data source, the first thing you need to do is to create an @IBOutlet for your UITableView in ViewController.swift. Add the following line to your ViewController, before the viewDidLoad method:

@IBOutlet var tableView: UITableView! 

Now, using the same technique as before when designing UITableViewCell, select the UITableView in your Main.storyboard file and use the Connections Inspector to drag a new outlet reference to the UITableView. Make sure you select the tableView property and that's it. You've now hooked up your UITableView to the ViewController code.

To make the ViewController code both the data source and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required