PDA

View Full Version : Window doesn't show




Dreamspinner
Feb 15, 2013, 07:08 AM
I have a preferences window that should open when the Main Menu item "Preferences" is selected. It's action is set to showPreferencePanel in AppController.m. The code is called, I can step thru it in the debugger, but has no effect. What am I missing? The debug console shows

2013-02-15 09:47:40.533 RotorDCU[22113:303] -[PreferenceController loadWindow]: failed to load window nib file 'Colors'.


// PreferenceController.h
#import <Cocoa/Cocoa.h>

@interface PreferenceController : NSWindowController{
IBOutlet NSColorWell *bgColorWell;
IBOutlet NSColorWell *textColorWell;

}
- (IBAction)setBGColor:(id)sender;
- (IBAction)setTextColor:(id)sender;
@end

// PreferenceController.m
#import "PreferenceController.h"
#import "AppController.h"

@interface PreferenceController ()

@end

@implementation PreferenceController

-(id)init
{
self = [super initWithWindowNibName:@"Colors"];
if (self) {
// Initialization code here.
}
return self;
}

- (void)windowDidLoad
{
[super windowDidLoad];

// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

- (IBAction)setBGColor:(NSColorWell *)sender {
}

- (IBAction)setTextColor:(NSColorWell *)sender {
}
@end

// AppController.h
#import <Cocoa/Cocoa.h>
#import "AMSerialPort.h"
#import <Foundation/Foundation.h>

@class PreferenceController;

@interface AppController : NSObject {
NSColor *myColor;
PreferenceController *preferenceController;
}

@property (nonatomic,retain) NSColor *myColor;

- (IBAction)showPreferencePanel:(id)sender;
@end

// AppController.m
#import "AppController.h"
#import "AMSerialPortList.h"
#import "AMSerialPortAdditions.h"
#import "PreferenceController.h"

@implementation AppController
@synthesize serialPort;
@synthesize myColor;

- (void)awakeFromNib
{
}

-(void)applicationDidFinishLaunching:(NSNotification *) notice
{
}
- (IBAction)showPreferencePanel:(id)sender{
if (!preferenceController)
{
preferenceController = [[PreferenceController alloc]init];
}
[preferenceController showWindow:self];
}
@end



ElectricSheep
Feb 15, 2013, 11:42 AM
Are you sure "Colors.xib" is assigned the correct Target Membership? Does it even exist and is named correctly?

Dreamspinner
Feb 15, 2013, 01:09 PM
Are you sure "Colors.xib" is assigned the correct Target Membership? Does it even exist and is named correctly?

AHA! You nailed it. It is actually named "PreferenceController". "Colors" is the title.