Search code examples
cocoansmenu

What does the `.title` property in `NSMenu` exist for?


I'm now building up a menu bar app in Cocoa, and uses NSMenu instance to assign to the .menu property of NSStatusItem. However, NSMenu is initiated by calling NSMenu(title: ) class method, while I don't know where the .title property is used in my app.

I tried to click on the menu bar app to expand or click on the inner element of NSMenu (NSMenuItem instance). However, I wasn't able to find anything I specified as the .title property (TITLE in my case, just for the illustration purpose's only).

So what is the purpose of specifying .title? Where does it used in my app?


Solution

  • It's used for Sub-Menus, like in your menu bar the "Edit" menu, which is a NSMenu.

    NSMenu Title