Window doesn't show

Discussion in 'Mac Programming' started by Dreamspinner, Feb 15, 2013.

  1. Dreamspinner, Feb 15, 2013
    Last edited: Feb 15, 2013

    macrumors member

    #1
    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'.

    Code:
    //  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
    
    
     
  2. macrumors 6502

    ElectricSheep

    #2
    Are you sure "Colors.xib" is assigned the correct Target Membership? Does it even exist and is named correctly?
     
  3. macrumors member

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

Share This Page