Re: [NSApp mainMenu] returns nil under 10.4.3
Re: [NSApp mainMenu] returns nil under 10.4.3
- Subject: Re: [NSApp mainMenu] returns nil under 10.4.3
- From: j o a r <email@hidden>
- Date: Tue, 29 Nov 2005 10:07:56 +0100
On 29 nov 2005, at 09.34, Alex Fischer wrote:
I have no idea why it works on 10.4.2. That's probably a bug.
Well, as it has always worked for me, I just thought that sending
"sharedApplication" or "run" to NSApp was setting up the NSMenu
object returned by "mainMenu".
As long as it's not the documented behaviour, I don't think that it's
reasonable to expect NSApplication to add any items at all to the
main menu. It should all be done by the programmer directly, or
indirectly via NSApplicationMain() + the main nib file.
Changing such a behaviour for a dot-release of the OS is a bit
unexpected though, and should probably have been mentioned in some
release notes. Perhaps it is? I haven't checked.
Even though I think it's a bit harsh to say that it's a bug to not
use NSApplicationMain(), I agree with John that there are very - very
- few cases where you would have to override the default convenience
methods for starting your app. In the cases where you do though, it
should of course be possible. This is currently trickier than what
you might expect and want, since the relevant API:s are somewhat
under-documented, and doesn't really behave as you would expect them to.
On 29 nov 2005, at 09.50, Steve Checkoway wrote:
I'm not seeing the part that says that even though a main menu is
displayed, this will return nil unless NSApplicationMain is called
first
Agreed, but this probably just works lik a lot of other accessor
methods that might not be populated until the setter is called. That
you have an empty application menu with the title set to the name of
your application is not necessarily a sign of having a main menu.
Note that the OS will set the name of this menu item, and whatever is
set in the nib file will be ignored.
That said, perhaps there should always be a main menu - even if it's
empty. File an enhancement request if you think that would make
sense, and make your life easier.
Next point, I agree that Joar is an expert and can do this. I am
not a Cocoa expert, I don't have 15 years of experience with NeXTSTEP.
Being called "expert" twice in one day is almost too much... ;-)
Just to make things clear: I also rely on the documentation, and
observed behaviour, in order to find out how these things work.
Sometimes that's not so easy, and sometimes you make incorrect
assumptions when you do. That's always going to be a problem when you
work with closed-source frameworks. If you need to ensure that a
particular implementation works, perhaps you could use a Apple
Developer Technical Support and a Technical Support Incident to find
out?
Third point, what is the correct way to start a nibless application
that allows full control over the main menu?
I think that the implementation that I posted previously, the one
that you quoted, should be fairly close. It's still working in our
application after the upgrade to Mac OS X 10.4.3.
If you post code snippets that illustrates how you do this, perhaps
we can offer some suggestions?
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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