I am having a very difficult time switching between forms in Cocoa interfaces. From my initial form and its delegate, I can hide the initial window then load and display the second window with all properties on it. This is working working... Alas, on attempting to return to the initial window, I hide the second window and the initial does not return...
Here are my .h and .m for initial form and for formTwo...
.h
#import <Cocoa/Cocoa.h>
@class frmTwoDelegate;
@interface AppDelegate : NSObject {
@private
frmTwoDelegate *_frmTwo;
}
@property (assign) IBOutlet NSWindow *window;
- (IBAction)BtnSwitchAction:(id)sender;
@end
.m
#import "AppDelegate.h"
#import "frmTwoDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
...
}
- (IBAction)BtnSwitchAction:(id)sender {
if (!_frmTwo) {
_frmTwo = [[DecriptDelegate alloc] initWithWindowNibName:@"frmTwo"];
[_frmTwo setFrmStart:self];
}
[_frmTwo showWindow:sender];
[_window setIsVisible:NO];
}
@end
Here are .h and .m for frmTwo
.h
#import <Cocoa/Cocoa.h>
@class AppDelegate;
@interface frmTwo : NSWindowController{
@private
AppDelegate *frmStart;
__unsafe_unretained NSTextView *_TxtView;
}
@property (retain) AppDelegate *frmStart;
@property (assign) IBOutlet NSWindow *frmTwo;
@property (unsafe_unretained) IBOutlet NSTextView *TxtView;
- (IBAction)BtnOpenActionPreformed:(id)sender;
- (IBAction)BtnBackActionPreformed:(id)sender;
@end
.m
#import "frmTwo.h"
#import "AppDelegate.h"
@implementation frmTwo
@synthesize frmStart;
- (id)initWithWindow:(NSWindow *)window
{
...
}
- (void)windowDidLoad
{
...
}
- (IBAction)BtnOpenActionPreformed:(id)sender
{
...
}
- (IBAction)BtnBackActionPreformed:(id)sender {
[frmStart ShowWindow];
[_frmTwo setIsVisible:NO];
}
@end