Skip to Content
Cocoa in a Nutshell
book

Cocoa in a Nutshell

by Michael Beam, James Duncan Davidson
May 2003
Intermediate to advanced
566 pages
27h 29m
English
O'Reilly Media, Inc.
Content preview from Cocoa in a Nutshell

Menus

The NSMenu and NSMenuItem classes implement menus in Cocoa. NSMenu provides an implementation for actual menus, while NSMenuItem represents individual items within menus. An application’s menus appear in the main menu bar across the top of the screen. By and large, an application’s main menu is assembled in Interface Builder, which provides facilities for editing menu structures and setting menu item targets and actions. Additionally, Interface Builder has several pre-configured menus, such as File and Edit that contain standard menu items familiar to users. An application’s main menu is contained in the main nib of an application.

Every application also has a Dock menu, which pops up when you right-click on an application’s Dock icon. Dock menus are easily created in Interface Builder by connecting an instance of NSMenu to the File’s Owner’s dockMenu outlet. Alternatively, the application delegate can supply a Dock menu by implementing the method applicationDockMenu: (this is useful if you want to dynamically reconfigure the menu). A third way of specifying a Dock menu is to assemble the NSMenu object in a nib and specify the nib’s file name in the application’s Info.plist file under the AppleDockMenu key.

NSView objects manage contextual menus. In Interface Builder, every view has a menu outlet, which can be connected to an NSMenu object. The menu that you connect to this outlet will appear as a contextual menu when you right-click over the view. Contextual menus can ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Pro Objective-C

Pro Objective-C

Keith Lee
More iPhone Development with Objective-C

More iPhone Development with Objective-C

David Mark, Jayant Varma, Jeff LaMarche, Alex Horovitz, Kevin Kim

Publisher Resources

ISBN: 0596004621Errata Page