Re: -viewDidMoveToWindow without subclassing? NSViewController?
Re: -viewDidMoveToWindow without subclassing? NSViewController?
- Subject: Re: -viewDidMoveToWindow without subclassing? NSViewController?
- From: Graham Cox <email@hidden>
- Date: Thu, 16 Apr 2009 12:15:44 +1000
On 16/04/2009, at 12:09 PM, Jerry Krinock wrote:
I have the contentView of an NSTabViewItem controlled by an
NSViewController. I need to run code in there to initialize things
when the nib is loaded, but not before the view has a -window.
Putting the code in -awakeFromNib is no good because it will not yet
be in a window if another tab is selected during nib loading. I
believe it would work to subclass the content view and implement -
viewDidMoveToWindow, but that seems silly since it would be the only
code in this subclass.
It seems like NSViewController should give me a "view has moved to
window" notification or delegate message, but I can't find any.
There is a -loadView, but Cocoa does not invoke it when loading or
moving the view.
Is there a better way -- or, what have I done wrong?
The usual way is to implement -windowDidLoad (a NSWindowController
method) and put your code in there. This is called when the window is
first shown by the window controller, since windows are constructed
lazily.
--Graham
_______________________________________________
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