Connecting the table view to LocationViewController

Currently, LocationViewController has no way of communicating with the table view. In this section, you will create a new outlet in LocationViewController and assign the table view to it. Follow these steps to do so:

  1. Click the Navigator and Inspector buttons to hide the Navigator and Inspector areas, as shown in the following screenshot:

  1. Click the Adjust Editor Options button, as shown in the following screenshot:

  1. Choose Assistant from the menu, as shown in the following screenshot:


  1. Click the table view in the document outline. The assistant editor should be set to Automatic > LocationViewController.swift:


  1. Ctrl + Drag from the table view to the space just above viewDidLoad():


  1. In the pop-up menu, enter tableView in the Name field and click Connect:


  1. The tableView outlet has been added to LocationViewController and connected to the table view in the storyboard:

  1. Click the x button to close the assistant editor:


As you saw in the playground, in order for a table view to display data and respond to user interaction, a view controller for a table view needs to adopt the table view data source and delegate protocols and implement the required methods. You will do that next.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.90.182