NSWindowController and NSViewController

Probably a pretty simple question, but I can't get around it.

I would like to create a kind of wizard: NSWindow displayed as a sheet from another NSWindow and should show three different NSView one after another.

I think I should create a custom NSWindowController and three NSViewController , but I don't know how to configure the controllers and how to share views.

+7
source share
2 answers

In short, your window controller will instantiate the three view controllers, have a host view, and add -[NSView addSubview:] or delete -[NSView removeFromSuperView] dispatcher views as host -[NSView removeFromSuperView] . Depending on how you structure your code, you can also use -[NSView replaceSubview:with:] to replace the subtitle with another.

Apples Viewing the code for a sample controller involves switching views using view controllers.

+12
source

@Bavarious asnwer is good, people like me always need a good piece of code:

 appDelegate = (AppDelegate*)[[NSApplication sharedApplication] delegate]; self.masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil]; [appDelegate.window.contentView replaceSubview:self.view with:self.masterViewController.view]; 

I am creating an appDelegate object because it is being called from NSViewController , otherwise you might get a view from yourself.

+1
source

All Articles