Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6153573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:07:00+00:00 2026-05-23T20:07:00+00:00

First, I’d like to point out that this question is probably already asked, I

  • 0

First, I’d like to point out that this question is probably already asked, I just couldn’t find any answers from them.

So, I’m programmatically trying to create a NSMenu and NSMenuItem to the main bar, so fe. NSMenu would be File and then it would have 3x NSMenuItem in it, New, Open and Save.

But nothing’s working, here’s what I have currently:

NSMenu *fileMenu = [[NSMenu alloc] initWithTitle:@"File"];
NSMenuItem *newMenu = [[NSMenuItem alloc] initWithTitle:@"New" action:NULL keyEquivalent:@""];
NSMenuItem *openMenu = [[NSMenuItem alloc] initWithTitle:@"Open" action:NULL keyEquivalent:@""];
NSMenuItem *saveMenu = [[NSMenuItem alloc] initWithTitle:@"Save" action:NULL keyEquivalent:@""];
[newMenu setMenu:fileMenu];
[openMenu setMenu:fileMenu];
[saveMenu setMenu:fileMenu];

But nothing happens, I’m pretty sure I have to tell the application that it should use fileMenu, but how do I do that, and if that’s not the problem, then what is? I’m pretty new at this stuff, but interested in learning, so just any tip will be better than nothing!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:07:01+00:00Added an answer on May 23, 2026 at 8:07 pm

    When you set the menu, you set the menu that appears for that item, not its parent menu.

    To add those three items to your menu, use:

    [fileMenu addItem: newMenu];
    [fileMenu addItem: openMenu];
    [fileMenu addItem: saveMenu];
    

    And then to add the menu to the menu bar:

    NSMenuItem *fileMenuItem = [[NSMenuItem alloc] initWithTitle: @"File"];
    [fileMenuItem setSubmenu: fileMenu]; // was setMenu:
    [[NSApp mainMenu] addItem: fileMenuItem];
    [fileMenuItem release];
    

    Every menu owns multiple menu items; a single menu item can be responsible for a submenu; and all these menus are anchored to the UI by [NSApp mainMenu].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First let me say that I really feel directionless on this question. I am
First of all, this is probably a stupid question, but I'm new and still
First off, I know this may be a very stupid question, so don't shoot
First of all I am new to javascript so this question might be stupid.
First, let's get the security considerations out of the way. I'm using simple authentication
First off, there's a bit of background to this issue available on my blog:
First off, I'm working on an app that's written such that some of your
I've got a string that has curly quotes in it. I'd like to replace
First of all: this is not a homework assignment, it's for a hobby project
This is beyond both making sense and my control. That being said here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.