O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

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

Making Connections

Creating views and laying out your user interface is not the only purpose of Interface Builder. You can also use Interface Builder to wire up connections between your views and your Swift code.

Setting target-action pairs for VocalTextEdit’s buttons

When you run your application and Main.storyboard is loaded, the Cocoa runtime will create an instance of your ViewController class, configure its views, and set up any outlets and actions you have configured. For VocalTextEdit, you want the speakButtonClicked(_:) method to be called on the instance of ViewController that is managing the current document. Control-drag from the Speak button to the icon representing the ViewController, as in Figure 26.19.

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