Connecting our Table View with our Location View Controller

Currently, we have no way to communicate with our Table View and our Location View Controller. Let's see how we can connect these two:

  1. Open the LocationViewController.swift file and add the following code after the class declaration:
@IBOutlet weak var tableView:UITableView!
  1. Save the file by hitting cmd + S. Your file should look like the following, with an empty circle next to the variable:

Before we get started, we are going to clean up our LocationViewController.swift file. Delete everything after viewDidLoad():

Next, let’s connect our table view to the file.

  1. Open Explore.storyboard again and make sure that you have the Location View Controller selected in the Outline view.

 

  1. Then, in the Utilities panel, select Connections inspector. Under the Outlets section, you will see an empty circle, tableView:

Click and drag the empty circle to the Table View in the storyboard:

We have now connected our Table View to our Location View Controller.