swdev
swdev

Reputation: 5157

How do you create and attach MainMenu.xib manually in Cocoa Application?

I already started working on a few small Cocoa Application. It works just fine, but now I want to create my own MainMenu (not using the default MainMenu.xib created by XCode).

But I got a few obstacle. First, I add two XIB and its corresponding NSWindowController. The idea is the first xib will call the other xib file. But as these two xib file is a Window and with its NSWindowController, I got quite confuse on how to add the MainMenu. I create another XIB file with name MainMenu.xib, and in the startup XIB file, I do this :

 - (void)windowDidLoad
   {
     [super windowDidLoad];
     mainMenu = [[NSMenu alloc] initWithWindowNibName:@"MainMenu"];
     [self setMainMenu:mainMenu];  
   }

but it's not working. The first startup XIB didn't display the MainMenu at all (so I can't quit the application).

As for the MainMenu.xib itself, I already connect it with the startup XIB (using NSOBject that dragged into left pane of the XIB Designer).

What is the proper way of creating main menu for multi XIB like this? I hope I state my problem correctly, as I quite new in this Cocoa things :)

Thanks in advance!

Upvotes: 1

Views: 1295

Answers (1)

Yuji
Yuji

Reputation: 34185

You don't have to create another xib to change the main menu bar.

You just edit the menu bar inside the MainMenu.xib in the interface builder, that's it!

Upvotes: 2

Related Questions