In my App Delegate, I load the "MainView" of the MainViewController
as follows:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
MainViewController *mainvc = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
[self.window setContentView:mainvc.view];
}
Within the "MainView", I have a button connected to the following IBAction
method:
- (IBAction)switchToOneView:(id)sender {
OneViewController *onevc = [[OneViewController alloc] initWithNibName:@"OneView" bundle:nil];
[self.view.window setContentView:onevc.view];
}
I want to use this button to change the content view of the main window. Unfortunately this does not work and I receive the following error:
[NSLock switchToOneView:]: unrecognized selector sent to instance 0x6000000c5b00
Any suggestions on how to switch the content view of a NSWindow
with the view of a NSViewController
?
Here's a diagram of what I'm trying to accomplish:
A button in the "MainView" will change the content view to "OneView" or "TwoView". Once that view is loaded, I would like to click a button in that view to remove it and return back to the "MainView".