Hiding the menubar on OS X
23rd February 2005
I’m quite fond of the Apple mailing lists, particularly java-dev and cocoa-dev. They’ve helped me solve quite a few problems on occasion. I once needed to hide the menubar on top of the screen in OSX and I found that it is as simple as this:
[NSMenu setMenuBarVisible:false];
Let’s say you want to pass some arguments to your Cocoa program from the command-line, so how do you do it? If you look at the main.m file that XCode generates you can see that all it does is create an instance of NSApplication and passed the arguments to it, but where do these arguments go? How do I access them from within some other class. Once again, the simply answer, from cocoa-dev is to use NSProcessInfo as so:
NSArray *args = [[NSProcessInfo processInfo] arguments];
This puts them all in a nice array for you. Took a while to figure all these things out, many thanks to the Apple mailing-lists.
Just in case you’re wondering why I didn’t read the API docs, well it isn’t obvious from reading any of the docs that command-line arguments end up in NSProcessInfo. I googled forever but couldn’t find an explanation and read many docs. In the end the lists had already got the solution and I should have looked there in the first place.
Posted in coding | No Comments »