awakeFromNib and applicationDidFinishLaunching

Whenever Apple announces a new Xcode or a new OS revision, you can feel how Apple wants to change things by looking at the code Xcode generates template codes.

I noticed some direction of drive in code design with iPhone SDK and generated project codes targeted for iPhone. Now again with Snow Leopard, I noticed another one.

Traditionally, programmers who have written codes for Mac OS X, have written their initialization code in awakeFromNib, as well as each object’s init method. It is reasonable choice, because every object will get awakeFromNib call if the object is instantiated in NIB/XIB file.

However, with default codes generated by Xcode on Snow Leopard, Apple started to put applicationDidFinishLaunching method in default. What does this mean? Probably Apple wants us to put initialization codes in applicationDidFinishLaunching. Problem is that only App delegates or child class of NSApplication will get the notification.

There is more detailed explanation at Cocoa Is My Girlfriend. Try reading it at least once. It is really well written.

ADDED : It seems to me that Apple people want to unify the coding style or how codes should be organized for iPhone/iPod touch and Mac. If you create a new project targeted for Mac, it generates an App Delegate object by default. In previous version, it didn’t. So, I used to generate a controller class and start implementing code based on the controller. Sometimes if I really needed to get App notification or some method only available for NSApplication or its delegate, I declared an app delegate.

The new template codes for Mac look very similar to that of iPhone project template codes in that sense.
Is this another sign of Apple Tablet? If the three devices use Cocoa/Objective-C but in different style a little bit, then it can be very confusing. Using same/similar Cocoa call for iPhone was a big plus, but if it reaches a certain level, it can be confusing a lot. Probably Apple people are trying to standardize or make the code style or pattern uniform across iPhone/Mac/Tablet. Just my guess…


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: