Re: -windowDidLoad not getting called
Re: -windowDidLoad not getting called
- Subject: Re: -windowDidLoad not getting called
- From: Chris Hanson <email@hidden>
- Date: Mon, 21 Apr 2008 23:01:48 -0700
On Apr 21, 2008, at 5:34 PM, Rick Mann wrote:
That's all a rather unfortunate inconsistency (and part of why I sit
here learning Cocoa and thinking, "I thought Cocoa was supposed to
be this great thing").
I basically want my controller to go do some stuff after it and the
window are loaded. -setWindow seems like an ugly place to do this,
and -init is probably too early. Is there a better place?
It's not so inconsistent, really. A window controller is intended to
be File's Owner for the nib containing a window, not be a separate top-
level object in some other nib. If you do that, then the window
controller will load the nib itself, and thus load the window within
it too and send itself -windowDidLoad at the end. Since your window
controller isn't what loaded the nib containing the window, its -
windowDidLoad won't be invoked.
You could refactor your nib so that your window and its owning window
controller are in their own nib, with the window controller as File's
Owner; check out "Decompose Interface" in Interface Builder 3 for an
easy tool that will get you partway there. (You'll have to switch
from using a separate object to using File's Owner as an instance of
your NSWindowController subclass yourself.)
NSWindowController isn't the only class in Cocoa that works this way;
NSViewController also does, for similar reasons. It's a great
substrate on which to build reusable "component" views.
-- Chris
_______________________________________________
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