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.
Get Swift Programming: The Big Nerd Ranch Guide 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.