Re: NSTabView Problems
Re: NSTabView Problems
- Subject: Re: NSTabView Problems
- From: Kyle Hammond <email@hidden>
- Date: Wed, 13 Mar 2002 01:25:03 -0600
I've used NSTabView extensively with adding and deleting tabs. I
created one NSTabView with all the tabs in IB and remove them and add
them as needed at run time. I haven't run into any problems during this
process, including removing all tabs (the NSTabView looks like a blank
box when it has no tabs).
Since you're getting "out of bounds" exceptions, I'd guess that you're
keeping track of the indices of what tabs are currently in the NSTabView
incorrectly. I suggest either keeping track of the NSTabViewItems in
your own array, or finding them by identifier instead. The identifier
method works very well in these dynamic situations; it's the same as
using the identifier on NSTableColumns in order to allow the user to
reorder the columns. Of course, you still have to keep track of the
identifiers some how (NSMutableArray probably).
I use code similar to this below for adding an NSTabViewItem:
// Only add the tabViewItem if it's not already present.
if ( [ mTabView indexOfTabViewItem:tabViewItem ] == NSNotFound )
[ mTabView addTabViewItem:tabViewItem ];
And this code for removing an NSTabViewItem:
// Only try to remove it if it's in there.
if ( [ mTabView indexOfTabViewItem: tabViewItem ] != NSNotFound )
[ mTabView removeTabViewItem: tabViewItem ];
On Saturday, March 9, 2002, at 12:05 PM, Matt Massicotte wrote:
I'm using a NSTabView that has tabs added and deleted a lot. Very
similar to Limewire's interface, if you are familiar with it.
My problem is that the method removeTabViewItem returns an array out of
bounds exception in two (really weird) situations.
1) removing the last (rightmost) TabViewItem
2) removing the first TabViewItem when there are only two tabs.
Does anyone have any insight on why this happens? It might have to do
with how I'm adding the tabs, but all I do is create a NSTabViewItem
instance and add that to the view.
Another weirdness is that it seems that the view doesn't like having
zero tabs, so I start the view off with a placeholder tab, and modify
it's label, identifier, and view. This might have something to do with
it also.
---------------------
Kyle Hammond
email@hidden
http://twincities.bcentral.com/twincities/stories/2001/06/11/focus1.html -
CodeBlazer in the news
http://www.CodeBlazer.com/ - multimedia software solutions
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.