Re: timing of showing a window and setting display attributes of controls on that window
Re: timing of showing a window and setting display attributes of controls on that window
- Subject: Re: timing of showing a window and setting display attributes of controls on that window
- From: Randall Meadows <email@hidden>
- Date: Tue, 3 Jun 2008 18:12:50 -0600
On Jun 3, 2008, at 6:06 PM, Stuart Malin wrote:
I have a window with a few NSTextFields. The window has a controller
(sub class of NSWindowController). The window is loaded from a Nib.
I set the stringValue of the NSTextFields using the -setStringValue.
I tried doing this before showing the window:[super showWindow:self];
I moved the -showWindow to before I set the values; the values now
display.
1. Why doesn't this work when -showWindow is invoked after setting
the control's display values? Is the window not fully "alive" (in
some sense) after the Nib is loaded but before it is first shown?
Yeah, when you "load" a window using a controller, it's lazily loaded--
it's not loaded until it's really needed to be, like when you show
it. So, setting the fields beforehand is not being done properly
because they haven't yet been loaded from the nib, so the ivars are
nil. It's legal to send messages to nil in ObjC, and there's no
notification that you're doing so.
2. I am doing what I do because I want the window to appear with the
display values set. Do I not need to worry about the order of the -
showWindow invocation -- that is, is the window displayed
immediately upon execution of the -showWindow, or on the next
iteration of the run loop (hence, my method calls to set the values
of the controls occur before the window is displayed)?
I think the latter is true.
_______________________________________________
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