• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSapp mainMenu] returns nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSapp mainMenu] returns nil


  • Subject: Re: [NSapp mainMenu] returns nil
  • From: William Bumgarner <email@hidden>
  • Date: Tue, 4 Apr 2006 08:44:20 -0700

On Apr 4, 2006, at 1:46 AM, Christian Stieber wrote:
Although, something I still want to try some time is to use
Interface-Builder to just make a dummy menu to kickstart things,
load that, and see it if helps.

Beyond being an interesting intellectual exercise, I'm don't understand why you are fighting so hard with Cocoa. The easy way would be to simply create a minimal main NIB file, load, modify, and initialize. If you look in a default Application NIB file as created by Interface Builder, the menu items are connected via target/ action to the quit/hide/etc actions. So, it isn't totally surprising that not loading a NIB containing a main menu and not otherwise creating a main menu would lead to unexpected behavior.


The documentation states that NSApplicationMain() is equivalent to:

void NSApplicationMain(int argc, char *argv[]) {
    [NSApplication sharedApplication];
    [NSBundle loadNibNamed:@"myMain" owner:NSApp];
    [NSApp run];
}

Given that your code all ends with [NSApp run], it would appear that your code is trying to duplicate the above while initializing your own main menu?

Have you tried creating an appropriately configured NSMenu instance and calling -setMainMenu: on NSApp (instead of - loadNibNamed:owner:)? Make sure you set up target/action for terminate:, hide:, and any other standard behaviors your app might need.

b.bum

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: [NSapp mainMenu] returns nil (From: Christian Stieber <email@hidden>)

  • Prev by Date: Re: untar into app bundle
  • Next by Date: Re: Robustness of CoreData against malicious documents?
  • Previous by thread: Re: [NSapp mainMenu] returns nil - Solution :-)
  • Next by thread: "Yellow Box" resurrection. Should we hold our breath for it?
  • Index(es):
    • Date
    • Thread