Re: Accessing NSWIndowController attribute from a subview in IB
Re: Accessing NSWIndowController attribute from a subview in IB
- Subject: Re: Accessing NSWIndowController attribute from a subview in IB
- From: Quincey Morris <email@hidden>
- Date: Thu, 28 Apr 2011 10:26:43 -0700
On Apr 28, 2011, at 04:28, Ben Golding wrote:
> In the window that's loaded from Face.xib, there's a custom view (SundialView) which needs to access the sundial instance variable in File's Owner. I just don't seem to be able to control-drag in some order to hook them up and I think I should be able to.
You could control-drag to connect a controller *outlet* to a view.
You could control-drag to connect a control's *action* to a target.
But you're doing neither here. You don't need to. The code in your custom view can simply access the controller property directly as '[[[self window] windowController] sundial]'.
There are only a couple of gotchas in this.
First, make sure that the window controller's 'window' outlet is actually connected to the window in the NIB.
Second, the view's access to the window's windowController property won't be available until some point in the NIB loading process (specifically, not until after the view is added to the window's view hierarchy). If you try to reference the property too early, you'll get nil. 'viewDidMoveToWindow:' is a good place to intervene if you want to know when the window controller is available to the view.
_______________________________________________
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