Skip navigation.
 
mlRe: Initializing the menubar without Interface Builder
FROM : mmalc crawford
DATE : Sat Nov 03 19:29:48 2007

On Nov 3, 2007, at 10:12 AM, Robert Nikander wrote:

> I could answer this myself if I could see the source code for 
> NSApplicationMain, but that's not available, correct?
>

<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html
>

"The main() function Xcode creates begins by calling a function named 
NSApplicationMain(), which is functionally similar to the following:"...

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



See also <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Miscellaneous/AppKit_Functions/Reference/reference.html#//apple_ref/c/func/NSApplicationMain
>.
"Creates the application, loads the main nib file from the 
application’s main bundle, and runs the application. You typically 
only call this function once, from your application’s main function, 
which is usually generated automatically by Xcode."

So, particularly with reference to <http://developer.apple.com/DOCUMENTATION/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html
> you can fill in a little more detail:


void NSApplicationMain(int argc, char *argv[])
{
    NSDictionary * infoDictionary = [[NSBundle mainBundle] 
infoDictionary];

    NSString *principalClassName = [infoDictionary 
objectForKey:@"NSPrincipalClass"];
    Class principalClass = NSClassFromString(principalClassName);
    [principalClass sharedApplication];

    NSString *mainNibFile = [infoDictionary 
objectForKey:@"NSMainNibFile"];
    [NSBundle loadNibNamed:@"mainNibFile" owner:NSApp];

    [NSApp run];
}


mmalc

Related mailsAuthorDate
mlInitializing the menubar without Interface Builder Robert Nikander Nov 3, 18:12
mlRe: Initializing the menubar without Interface Builder Jeff Johnson Nov 3, 18:37
mlRe: Initializing the menubar without Interface Builder Jeff Johnson Nov 3, 18:46
mlRe: Initializing the menubar without Interface Builder mmalc crawford Nov 3, 19:29
mlRe: Initializing the menubar without Interface Builder Robert Nikander Nov 3, 19:54
mlRe: Initializing the menubar without Interface Builder Robert Nikander Nov 3, 20:08
mlRe: Initializing the menubar without Interface Builder mmalc crawford Nov 4, 00:13
mlRe: Initializing the menubar Robert Nikander Nov 4, 01:15
mlRe: Initializing the menubar Eric Schlegel Nov 4, 17:25
mlRe: Initializing the menubar Robert Nikander Nov 4, 18:05