I have already spent 2 full days trying to figure out how to use NSViewControllers to create a multi-user application.
That's what I'm doing.
I have 2 View Controllers and MainMenu.xib Window. I also have an AppController, which is the delegate for both view controllers.
When I launch the application, I am first greeted by the view of the MainMenu.xib window, in which there is a button. When this button is clicked, an IBAction is sent to appController and asks SecondViewController to display it. So far, everything is correct and the nib file is displayed correctly.
There is another button on secondViewController that sends another IBAction to the appController and asks for the FirstViewController to display, but nothing happens, no crash, no warning ... Any help would be greatly appreciated ... Thank you in advance for your patience ...
Here is the code for AppController.h:
#import <Foundation/Foundation.h>
#import "SecondViewController.h"
#import "FirstViewController.h"
@interface AppController : NSObject
@property (strong) IBOutlet NSWindow *mainWindow;
@property (strong) IBOutlet SecondViewController *secondViewController;
@property (strong) IBOutlet FirstViewController *firstViewController;
- (IBAction)secondButtonfromsecondViewControllerClicked:(id)sender;
- (IBAction)buttonClicked:(id)sender;
@end
and here is the code for AppController.m:
#import "AppController.h"
@implementation AppController
@synthesize mainWindow = mainwindow;
@synthesize secondViewController;
@synthesize firstViewController;
- (IBAction)buttonClicked:(id)sender {
NSLog(@"button from second View Controller clicked");
self.secondViewController = [[SecondViewController
alloc]initWithNibName:@"SecondViewController" bundle:nil];
self.mainWindow.contentView = self.secondViewController.view;
[self.secondViewController.view setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
}
- (IBAction)secondButtonfromsecondViewControllerClicked:(id)sender {
NSLog(@"button from first ViewController clicked");
self.firstViewController = [[FirstViewController
alloc]initWithNibName:@"FirstViewController" bundle:nil];
self.mainWindow.contentView = [self.firstViewController view];
}
@end
Well, can someone help me, I just need one viewer application that displays the first ViewController with a button on the first viewController, which brings me to the second view controller with a second button, which returns me to my first view manager ... I already spent more than a week on it ... in vain ... PS: I do not need a button in the mainMenu.xib window and tabs.
source
share