O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

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

Set Up the Menu Item

Open MainWindowController.swift and, near the bottom of the definition of MainWindowController, add a new section Actions and a stub for an @IBAction.

 ​ ​ ​ ​/​/​ ​M​A​R​K​:​ ​-​ ​A​c​t​i​o​n​s​

 ​ ​ ​ ​@​I​B​A​c​t​i​o​n​ ​f​u​n​c​ ​s​h​o​w​D​i​e​C​o​n​f​i​g​u​r​a​t​i​o​n​(​s​e​n​d​e​r​:​ ​A​n​y​O​b​j​e​c​t​?​)​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​p​r​i​n​t​l​n​(​"​C​o​n​f​i​g​u​r​a​t​i​o​n​ ​m​e​n​u​ ​i​t​e​m​ ​c​l​i​c​k​e​d​"​)​
 ​ ​ ​ ​}

Open MainMenu.xib and add a menu item to the main menu for your application by dragging it out of the object library (Figure 24.3).

Figure 24.3  Adding a menu item

Adding a menu item

Change the title ...

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