Wiring up the button

A button works using target-action, like you learned about in Chapter 27. The button’s action is the message that you want sent when the button is tapped. The button’s target is the object to which that message should be sent.

In BNRAppDelegate.m, give the Insert button a target-action pair:

#pragma mark - Application delegate callbacks

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...

    // Create and configure a rounded rect Insert button
    self.insertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.insertButton.frame = buttonFrame;

    // Give the button a title
    [self.insertButton setTitle:@"Insert"
                       forState:UIControlStateNormal];

    // ...

Get Objective-C 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.