Cocoa using separate controller for an NSTabViewItem?

1k views Asked by At

I have an NSTabView that has different styles of NSTabViewItems. Is there a way that I can separate out the tab controller into a different class than my outerview controller? Just so that I can keep my code tidy. I'm also looking to keep the tab contents in a separate nib.

Note: This is for the NSTabViewItem NOT for UITabs (not the iPhone).

1

There are 1 answers

0
Ken Thomases On BEST ANSWER

Sure, but it takes a bit of setup in code. Create the separate NIBs, one for each view. Create a custom subclass of NSViewController to load and own each NIB and control the view within. Set the class of each view NIB's File's Owner to be the corresponding class. Connect outlets as desired.

The tab view would be basically empty when you configure it in its NIB. You'd add the tabs, but nothing in the views.

In the controller for the NIB with the tab view, in -awakeFromNib, instantiate the view controllers for each of the views that should go into the tab view. Set the views of these new view controllers as the views of the NSTabViewItems of the tab view.