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
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to