Outline of what Apple does when your app is launched?

Discussion in 'Mac Programming' started by GorillaPaws, Oct 25, 2009.

  1. macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #1
    I'm wondering if there's a resource where you can see exactly what happens when your app launches. I have a rough idea about several of the big steps (applicationDidFinnishLaunching, awakeFromNib etc.), but I would love to find an article/reference that goes literally step-by-step through the process of all the initial setup in a standard cocoa app.

    The reason I started thinking about this is I've been reading "Cocoa Design Patterns" which is quite excellent. In the notifications chapter I came across the line:

    It made me realize that there must be dozens of other objects that Apple is creating for me that I have know idea exist, and it would be interesting to see exactly what gets created when in the timeline. Does anyone know of a resource that documents this process?
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    The simplest method to finding out what is being run below your application code is to just get the debugger out and step into some Cocoa functions. Eventually you'll get down to the C level stuff and then into Assembly.

    Frankly I was amazed when I compared some C programs with a test Objective-C program and the amount of crap that gets run behind the scenes.
     
  3. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #3
    Somewhat easier than just stepping through things in gdb would be to use dtrace and/or Instruments to watch calls and allocations.
     
  4. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    The first, and likely only, thing you do in your main function in a Cocoa app is call NSApplicationMain:
    http://developer.apple.com/mac/libr...nce.html#//apple_ref/c/func/NSApplicationMain

    From there, the most "interesting" piece is loading of the main nib. This page has some information about what happens when you do this:
    http://developer.apple.com/mac/libr...bs.html#//apple_ref/doc/uid/10000051i-CH4-SW8

    Stepping through things, watching calls, etc. will certainly be of value/interest but i thought it might be of value to read the documents that detail the process so you have some of the high-level knowledge about the design as well as the low-level knowledge of the actual calls that go on.

    -Lee
     
  5. thread starter macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #5
    Thanks for your replies. I was hoping there'd be more info/easier to access than using dtrace or the debugger. I also found this article which didn't have all the detail I was hoping for but was helpful as a general overview. Hopefully someone finding this thread in a search will find it useful.
     

Share This Page