This is actually a two part question, hope my explanation is clear:
I have an NSViewController which can be configured to show a different custom view on part of its view. For example, its view can show either CustomViewA or a CustomViewB.
I was able to make this work by creating an NSViewController for each of the custom views and initializing MyViewController with either an NSViewController which handles the CustomViewA or an NSViewController which handles the CustomViewB. I use an NSBox and set its contentView to the view provided by the given NSViewController.
The problem with this approach is that I have an NSBox who's contentView will hold the "MyView" and then inside "MyView" I have another NSBox which will hold either the CustomViewA or the CustomViewB.
The other problem is that I'd like MyViewController to handle both the CustomViewA and the CustomViewB, opposed to having a separate NSViewController for each one of them.
Here is sample code of my current solution:
// How I initialize the NSViewControllers
CustomViewControllerA* cvc = [[CustomViewControllerA alloc] initWithNibName:@"CustomViewA" bundle:nil];
MyViewController* controller = [[MyViewController alloc] initWithCustomViewController:cvc nibName:@"MyView" bundle:nil];
//...
// In Controller of main view
- (void)awakeFromNib
{
// container is an NSBox*
[self.container setContentView:[self.myViewController view]];
}
//...
// In MyViewController
-(void)awakeFromNib
{
// content is an NSBox*
[self.content setContentView:[self.customViewController view]];
}
How can I have my CustomViewA and CustomViewB live inside MyView.nib and both of them use MyViewController as their Controller?
How could I have the main view hold a MyView instead of an NSBox?
Thanks in advance!