Connecting Buttons to Actions

When you Control-drag (right-drag) from a button to an IB object such as the File’s Owner view controller in the IB editor, IB presents a pop-up menu of actions to choose from. These actions are polled from the target object’s available IBActions. Connecting to an action creates a target-action pair for the button’s Touch Up Inside event. You can also Control-drag from the button to your code, and Xcode will add empty function definitions to your implementation file.

Alternatively, you can Control-click (right-click) the button in the document outline, scroll down to Touch Up Inside, and drag from the unfilled dot to the target you want to connect to (in this case, the File’s Owner object). The same pop-up menu appears, ...

Get The Core iOS Developer’s Cookbook, Fifth 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.