Simple structure:
exampleController.h :
#import <Foundation/Foundation.h>
@interface exampleController : NSWindowController {
@public
IBOutlet NSPanel *entryPanel;
@property (nonatomic, strong) IBOutlet NSPanel *entryPanel;
@end
exampleController.m :
#import "exampleController.h"
@implementation exampleController
@synthesize entryPanel;
- (id)init {
self = [super initWithWindowNibName:@"ExamplePanel"];
if (self) {
// Initialization code here.
NSLog(@"entryPanel: %@", entryPanel);
[self.entryPanel setTitle:@"TESTING!"];
}
return self;
}
randomController.m :
...
- (id) init {
self = [super init];
if (self) {
// loading our example controller if it isn't loaded yet.
if (!ourExampleController) {
ourExampleController = [exampleController alloc] init];
}
}
return self;
}
...and then later in the random controller within a method I show the NSPanel via:
[ourExampleController showWindow:self];
[ourExampleController window] makeKeyAndOrderFront:self];
My problem is that no matter what, the first time the NSPanel displays and shows itself the title is always still set to the title that it has in Interface Builder! Even though I explicitly set the title in the exampleController init method.
I've also tried throwing an NSLog(@"entryPanel: %@", entryPanel) in the init method for exampleController and at launch it is always NULL. I do not have to ALLOC all my IBOutlets in the init because I am already synthesizing them?
I've double checked everything in interface builder. The File Owner for the ExamplePanel.xib is set to the exampleController class. The window AND entryPanel outlets are both referencing the NSPanel in our xib file. What am I missing ??
Thanks in advance!
EDIT: Just to add. If I open the window (..and see the default IB title) and then close it and reopen it with a method that changes the title - it seems to work! This problem seems to only reside with the window first opening. It seems like my properties are not being alloc'd until the window first opens?