NSMenuItem Class

The NSMenuItem class contains all the information relating to a specific menu item. Several attributes, which are shown in Table 16.1, are common to all menu items.

Table 16.1. Menu Item Properties
Menu Item Property Purpose
title The text displayed on the item, such as Cut. An NSString object.
image An optional NSImagethat is displayed to the left of the menu item’s title.
key equivalent The key that can be used in conjunction with the Cmd key to activate the item from the keyboard. (Cmd-C for Cut) An NSStringobject.
target The target object that will receive a message when the item is chosen. Often, this is nil, which sends the message to the first responder.
action The Objective-C selector for the action message to be sent ...

Get Cocoa® Programming 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.