Re: Beginner pleads for help...
Re: Beginner pleads for help...
- Subject: Re: Beginner pleads for help...
- From: Stéphane Sudre <email@hidden>
- Date: Wed, 4 Jul 2001 15:17:48 +0200
I had hoped that you would simply create a new nib file, then load that
nib file at run time and show the window. I'm obviously missing
something rather basic here, and would be greatly appreciative of any
advice from anybody! Many thanks in advance.
You're on one of the right ways. You need not forget to set the File's
owner to be a Secondary Controller Instance.
Here are some code (typed in Mail.app so may contain some bugs):
-----
#import <AppKit/AppKit.h>
#import "SecondaryController.h"
@interface MainController: NSObject
{
SecondaryController * subController_;
// Add your own Outlets here
}
@end
-----
#import "MainController.h"
@implementation MainController
- (void) awakeFromNib
{
subController_=[SecondaryController alloc];
// Do your own stuff here
}
----
#import <AppKit/AppKit.h>
@interface SecondaryController : NSObject
{
IBOutlet id anOutletOfTheSecondaryWindow_;
}
- (void) showWindow;
@end
-----
#import "SecondaryController.h"
- (void) showWindow
{
if (! anOutletOfTheSecondaryWindow_)
{
if (![NSBundle loadNibNamed:@"YourSecondaryNib" owner:self])
{
NSLog(@"Failed to load YourSecondaryNib.nib");
NSBeep();
return;
}
}
[[anOutletOfTheSecondaryWindow_ window] makeKeyAndOrderFront:self];
}
@end