I’m curious to know which of these events is processed firt. I’m thinking open since it is associated with the application. Whereas awake from nib can be associated with windows.
I ask this because I’ve got code in an open that needs to execute before the code in an awake from nib and I want to make sure that’s going to work.
I connected a handful of handlers to both the fileowner and window properties, and here’s the order I got them in…
‘opened’ → window
‘awake from nib’ → app
‘awake from nib’ → window
‘launched’ → app
The “open” handler for the file’s owner is not actually what you’d think. It does not fire when you “open” the program, but rather when something is trying to be opened by the app. You should use the ‘launched’ handler to initialize app variables… or the “awake from nib” handler of the app if you need to initialize before the window fires it’s awake from nib. Like handlers are always called starting at the application level and then working down. For example, if you attach an awake from nib handler to both the app and a window, the app’s handler will be called first. Check out this doc at apple for the firing order of the handlers. You can also view apple’s reference for the application object for more info about available handlers. I just set up a test program with the handlers I wanted to check, each with a “display dialog…” as it’s code to execute when fired to see which order they came in.
Thanks for the info. I have bookmarked the page with the order that you shared.
I did realize in seeing your answer that I did not identify one of the events properly. So I tested like you did and found in addition that the “on open names” event does not occur until after the “on awake from nib theObject” so code I had in one was not being executed first as I had thought.