code implementation

Since I am new at ASOC I need some help to understand if there are general rules on how to use code in " applicationWillFinishLaunching_(aNotification)" and “awakeFromNib()” handlers


Well, these are places where you want to put code that you need to have run when your app first starts up. awakeFromNib is called first, then applicationWillFinishLaunching and finally applicationDidFinishLaunching if you want to use that one too (there is also the application:openFile: method that is called in between the “will” and “did” finish launching methods if you double click on a file that was created by your app). I generally put everything in applicationWillFinishLaunching since that’s the one that is included in the template for a new project. I think that is probably sufficient for most simple projects.

I’m not sure why you would use the awakeFromNib method instead of one of the others. Maybe others can speak to that.


Hello t524ube,

Ric is right, when applicationWillFinishLaunching there is still time to set up all your interface elements. You cannot rely on the order the awakeFromNibs are called, and this multiplies useless tests.


awakeFromNib() is something you’re more likely to use in a class that isn’t the application delegate.


I’m using awakeFromNib in the application delegate class to initialize components which directly affect bindings like NSValueTransformer, to register user defaults (even preferable +(void)initialize) or to check system version or network reachability