Re: -windowDidLoad not getting called
Re: -windowDidLoad not getting called
- Subject: Re: -windowDidLoad not getting called
- From: Ken Thomases <email@hidden>
- Date: Mon, 21 Apr 2008 19:21:33 -0500
On Apr 21, 2008, at 6:15 PM, Rick Mann wrote:
I started a very simple non-document Cocoa app project. I added a
controller class derived from NSWindowController, and added an
NSObject to my .xib to represent it. I've connected an outlet in my
controller to a field in the window, and a button in the window to
an action in the controller. I've also set the NSWindowController's
window outlet to the window.
When the app launches, I see the window, and I can click the button
and my action is called (and it updates the field). But, -
windowDidLoad is never called.
What did I forget?
Sometimes an NSWindowController is instantiated in a NIB as a
controller for a window in that same NIB. Other times, an
NSWindowController is outside the NIB that contains its window, and
is used to load that NIB.
I suspect that -windowDidLoad is only called in the latter case.
Read the description of the -window and -loadWindow methods, which
describes how -windowDidLoad is called.
In the former case, the NSWindowController isn't initialized with a
NIB. It's just initialized with -init, which is presumably a cover
for -initWithWindow:nil. Then, the NIB loading machinery calls its -
setWindow: method to connect the outlet. At some later point, you
call -window but the window is already "loaded" in the sense that
it's set, so -window doesn't call -loadWindow and friends.
I hope that helps,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden