• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: -[NSView window] returns nil if its NSTabView not selected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSView window] returns nil if its NSTabView not selected


  • Subject: Re: -[NSView window] returns nil if its NSTabView not selected
  • From: Jim Correia <email@hidden>
  • Date: Wed, 7 Jan 2009 23:19:02 -0500

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 (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


References: 
 >-[NSView window] returns nil if its NSTabView not selected (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Large Core Data memory allocations for small rows
  • Next by Date: Re: -[NSView window] returns nil if its NSTabView not selected
  • Previous by thread: -[NSView window] returns nil if its NSTabView not selected
  • Next by thread: Re: -[NSView window] returns nil if its NSTabView not selected
  • Index(es):
    • Date
    • Thread