How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
- Subject: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
- From: Andrei Tchijov <email@hidden>
- Date: Mon, 13 Mar 2006 15:36:53 -0500
In my application I need to get reference to NSTabViewItem object
starting with its sub-sub-view. Firstly, I tried to traverse views
hierarchy via "[ view superview ]", but soon discovered that
NSTavViewItem object could not be found this way. After some
tinkering I come up with this :
...
id superview = [ startView superview ];
id subview = startView;
while (( superview != nil ) && ( ! [ superview isKindOfClass:
[ NSTabView class ]] )) {
subview = superview;
superview = [ superview superview ];
}
NSArray* tabViewItems = [ superview tabViewItems ];
for( int i = 0; i < [ tabViewItems count ]; i++ ) {
if( [[ tabViewItems objectAtIndex: i ] view ] == subview ) {
subview = [ tabViewItems objectAtIndex: i ];
break;
}
}
...
It works, but does not look right. I can not believe that there is
no better(simplier) way of doing it.
Any comments, suggestions will be highly appreciated
Andrei Tchijov
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden