I thought I had tried putting the setText statement after the addSubView but I 
went back and tried it again and it worked.  Thanks for the suggestion.

I cannot simply use IB to put the same label text in as the text label is 
calculated from user input.

Thanks!!!!!

Steve






On Sep 21, 2010, at Sep 21:6:03 PM, Quincey Morris wrote:

> On Sep 21, 2010, at 14:03, Steve Wetzel wrote:
> 
>> I could not get the 
>> 
>> [self.viewController1.label2.text 
>> 
>> or the 
>> 
>> [self view addSubview:viewController2.view];
>> 
>> to work for some reason.  Then it dawned on me that I could set the value 
>> right before I added the Subview!
>> 
>> [viewController2.label2 setText:label1.text];
>> [self.view addSubview:viewController2.view];
>> 
>> This works, although for some reason the label does not update unless I 
>> reload the view.  I will figure out what is going on there.
> 
> The usual cause of such behavior is the timing of NIB loading. There are 
> various points at which code can be executed (init..., awakeFromNib, 
> viewDidMoveToSuperview, etc), and it can be hard to keep track of the 
> correctness of your assumptions of what must have happened already.
> 
> In order to transfer the label successfully, you need both view1 and view2 to 
> have been loaded. Since NSViewController's 'view' method causes the view to 
> be loaded if necessary, you can be certain it's done *after* executing:
> 
>       [self.view addSubview:viewController2.view];
> 
> since that references both views. Did you try putting the other line:
> 
>       [viewController2.label2 setText:label1.text];
> 
> *after* the 'addSubview' line instead of before?
> 
> Is the label static in view1's NIB? If so, why can't you just use IB to put 
> the same label text in view2 and have no code at all?
> 
> 

_______________________________________________

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 arch...@mail-archive.com

Reply via email to