Linking the UI with the code

Storyboards provide a nice way to link the user actions with functions (code) in the app. Here is what you should do:

  1. Open Main.storyboard. To do it, you can use cmd + shift + O and start typing Main. Then select the file and hit return/enter.
  2. Select the button on the screen.
  3. Activate the Assistant Editor using the Assistant Editor button:

You should see the storyboard on the left, and the code of ViewControler.swift on the right:

  1. Right-click on the button in the storyboard. An action list should appear:

Get Learn Swift by Building Applications 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.