Skip navigation.
 
mlRe: best time to alter GUIs
FROM : Ken Thomases
DATE : Sat Mar 01 12:15:17 2008

On Feb 28, 2008, at 11:04 PM, Daniel Child wrote:

> I am trying to understand the interrelationship between various 
> method calls made once a window controller is instantiated. I am 
> loading a window controller from within a master controller. Data 
> passed from the master controller to the window controller is used 
> to programmatically alter the way the window appears The initial 
> master code is as follows:
>
> if (!fieldIDController)
> {
>  fieldIDController = [[Step3_FieldIDController alloc] init];
> }
> [fieldIDController setLocalDataCopy: [self dataValues]];
> [fieldIDController showWindow: self];
>
> Now here's the problem. It makes sense to check whether the 
> controller exists before adding local data and loading the window, 
> hence the if (!fieldIDController). But once init is called for 
> fieldIDController, all the following take place:
>
> - the init (which calls super = initWindowWithNibName:)
> - windowWillLoad (I tried the delegate)
> - awakeFromNib
> - windowDidLoad
>
> In other words, the window loads right away. I actually don't want 
> it to load until I have set the local data, as it is the local data 
> that will determine how the window should appear. Is there a way to 
> sneak the data in in before all the loading takes place?


Does your init method do anything else other than calling [super 
initWithWindowNibName:]?  In particular, if it calls [self window], 
that forces the loading (and awakening) of the NIB in order to 
reconstitute the window.

Perhaps the proper thing to do is pass the extra data into the init 
method of your custom controller class.

On a related note, where's the model in the MVC design?  Are the 
values with which you're configuring the controller (and subsequently 
the window) things which should be coming from the model?  Maybe the 
controller needs to be initialized with a relationship to a model, and 
then it will get what it needs from that model.

Another thing to consider: the above code looks as though it's 
designed to be run through multiple times.  Note, though, that the 
controller will only load the window once during its lifetime.  So, 
what do you hope [fieldIDController setLocalDataCopy: [self 
dataValues]]; will accomplish on subsequent passes through that code?

Cheers,
Ken

Related mailsAuthorDate
mlbest time to alter GUIs Daniel Child Feb 29, 06:04
mlRe: best time to alter GUIs Quincey Morris Feb 29, 09:04
mlRe: best time to alter GUIs Ken Thomases Mar 1, 12:15
mlRe: best time to alter GUIs Daniel Child Mar 3, 18:12
mlRe: best time to alter GUIs Ken Thomases Mar 3, 20:05
mlRe: best time to alter GUIs Quincey Morris Mar 3, 20:05
mlRe: best time to alter GUIs Daniel Child Mar 8, 04:38
mlRe: best time to alter GUIs Ken Thomases Mar 8, 07:11
mlRe: best time to alter GUIs Daniel Child Mar 12, 16:45
mlRe: best time to alter GUIs Ken Thomases Mar 13, 00:54