On Mar 5, 2011, at 4:00 PM, Matt Neuburg wrote:

I'm not grasping where there can be any source of confusion here. awakeFromNib is very simple: it is sent to an object after that object is instantiated from a nib. That's straightforward and dependable and clear - provided you know what a nib is, of course. The only "subtle difference" between Mac OS X and iOS in this regard is that in iOS you are enjoined to call super in your implementation. (There are some memory management differences for objects instantiation from nibs between Mac OS X and iOS, but that's a different matter.)

What you say about viewDidLoad is perfectly true, but should not be an issue provided you do in viewDidLoad only things that are suitable for viewDidLoad (i.e. things that can do no harm if done more than once)

I am pretty knew to cocoa and everything, and agree that awakeFromNib seems pretty straight forward, but I accidentally came across one of those double calls and found out something interesting: in a document template-based app, I connected a custom view to an outlet in my document class in order to setup it up and use it. Then I coincidentaly named a method in my document class as a setter to that outlet. Apparently that triggered the window controler (or some other part of the document architecture) to call awakeFromNib while my outlet was still nil (note that several other outlets in the same window were already instantiated...). I tested it many times and as soon as I changed the name of that method everything behaved as expected. Apparently the controller noticed the key-value path was available and offered a chance of bypassing the nib. Does that make any sense or am I totally wrong here? (Couldn't find an explanation in the documentation...)

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to