On Jan 7, 2009, at 10:36 PM, Jerry Krinock wrote:

In a view's -awakeFromNib, I often do some initializations which require the view's -window [1].
This worked fine until I put one of these views inside an  
NSTabView.  Now, it fails if the tab containing the view is not  
selected when the nib is loaded, because in this case -[NSView  
window] returns nil.  Since I don't see this fact in the  
documentation, I made myself a tiny test project [2], and indeed,  
that's what happens!
Consider how you might implement something like NSTabView.

One solution might be to hide the unselected views. Another solution might be to remove the unselected views from the tab view, and reinsert them as necessary. (In the history of Cocoa, being able to mark a view as hidden is a relatively recent addition.
Your empirical evidence suggests that NSTabView removes the unselected  
views from the view hierarchy.
NSTabView has a delegate which can be used for this purpose. A more  
general solution would be to wire up your window requiring code, and  
unwiring, in an override of one of these NSView methods:
- (void)viewWillMoveToWindow:(NSWindow *)newWindow;
- (void)viewDidMoveToWindow;

Jim
_______________________________________________

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