• 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: Initializing the menubar without Interface Builder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initializing the menubar without Interface Builder


  • Subject: Re: Initializing the menubar without Interface Builder
  • From: mmalc crawford <email@hidden>
  • Date: Sat, 3 Nov 2007 11:29:48 -0700


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


_______________________________________________

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


  • Follow-Ups:
    • Re: Initializing the menubar without Interface Builder
      • From: Robert Nikander <email@hidden>
References: 
 >Initializing the menubar without Interface Builder (From: Robert Nikander <email@hidden>)

  • Prev by Date: Re: Initializing the menubar without Interface Builder
  • Next by Date: Re: Adding an icon to the dock
  • Previous by thread: Re: Initializing the menubar without Interface Builder
  • Next by thread: Re: Initializing the menubar without Interface Builder
  • Index(es):
    • Date
    • Thread