Connecting Actions

So how do we get a tap on the Play button to do something? After all, we’ve been creating the user interface in the Main.storyboard file, but it doesn’t look like there’s any place in this editor to start writing code.

In iOS, we use Interface Builder connections to tie the user interface to our code. Using Xcode, we can create two kinds of connections:

  • An outlet connects a variable or property in code to an object in a storyboard. This lets us read and write the object’s properties, like reading the value of a slider or setting the initial contents of a text field.

  • An action connects an event generated by a storyboard object to a method in our code. This lets us respond to a button being tapped or a slider’s value changing. ...

Get iOS 10 SDK Development, 1st Edition 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.