Re: Setting up a main menu in a NIB(XIB)?
Re: Setting up a main menu in a NIB(XIB)?
- Subject: Re: Setting up a main menu in a NIB(XIB)?
- From: Russ <email@hidden>
- Date: Wed, 12 Nov 2008 08:47:28 -0800 (PST)
As I said, please save your typing on the "this is the wrong way" speech. This is an existing large cross-platform application, and like many other such, everything has been built elsewhere and is translated dynamically already, sans NIB. No way I'm going to rebuild and maintain a separate IB version. It all works very well, except for the mainMenu thing which seems to have been hardwired in some fashion incorrectly. A lot of Apple's material is structured around "you're building a tiny little app from scratch just for OS X" but surprise! the real world isn't like that. To a major extent the Cocoa API permits developers to control things directly (presumably it's what reads those nib files) and that is the way it HAS to be---it's fine & dandy for Apple to set up means to create little apps quickly, but those things all need to be able to be overridden for larger apps. The Apple Way isn't the Only Way or the One Right Way.
So please everyone, back to the original question (see my first mail) ----what is the minimum required to get the main menu in the XIB to show up, so I can rework it in code?
Thanks.
----- Original Message ----
Sent: Wednesday, November 12, 2008 12:28:46 AM
Subject: Re: Setting up a main menu in a NIB(XIB)?
On Wed, Nov 12, 2008 at 12:03 AM, Russ wrote:
> I am trying to get my application menu (About/Preferences/Services/Hide/Quit) set up. My app has no need for NIBs,
There's no such thing as a Cocoa app which has no need for a nib.
> aside from that I've been told that one is required to set up the application menu due to some indeterminate Cocoa hard-wiring. I'm correspondingly clueless about IB and happy to stay that way as much as possible, no value added.
What kind of app are you developing that you need no user interface?
Creating your UI in code is the incorrect approach.
You cannot avoid Interface Builder in any Cocoa app that presents UI.
Doing so will produce pain, suffering, and untold bugs for which you
will find no solution.
> When my app starts, at the place I'd like to set the main menu up (before the run loop starts, during my app's initialization), [NSApp mainMenu] is nil, so it hasn't been read yet. If I hand it my app's menu (File/Edit/etc), when the app starts I see my menu, but not the application menu About/Preferences/etc. I can understand that----assuming the NIB gets read at some later time---in [NSApp run]???
You're going about it backwards. If you use an IB-made Main Menu nib
as your app bundle's main nib file, its application menu will be set
up for you for free. Connect an outlet on your file's owner delegate
to the main menu and manipulate the menu via this outlet in your
delegate's -applicationDidFinishLaunching: method.
But why are you so determined to avoid the correct way to write Cocoa
applications?
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden