I have a Window with an NSTableView, a checkbox, and a label. These three items are wired to a NSWindowController subclass I named PrefWindowController:
@interface PrefWindowController : NSWindowController
//Members
@property (weak) IBOutlet NSButton *enabledCheckbox;
@property (weak) IBOutlet NSTextField *powerConnectedLabel;
@property (weak) IBOutlet NSTableView *ethernetAdaptorsTable;
@property (strong) EthernetAdaptorsDataSource* currentDatasource;
//Methods
-(IBAction)updateTable;
//...
//Overridden Methods
-(void) windowDidLoad;
@end
I overrode windowDidLoad and use that to set the DataSource on the NSTableView:
-(void)windowDidLoad
{
[super windowDidLoad];
[self updateTable:nil];
}
-(void) updateTable:(NSNotification*)notification
{
self.currentDatasource = [[EthernetAdaptorsDataSource alloc] initWithData: [[AppState getState] ethernetAdaptors]];
[self.ethernetAdaptorsTable setDataSource:self.currentDatasource];
[self.ethernetAdaptorsTable reloadData];
}
I have a timer that eventually triggers a reload of the data. It's a little convoluted, but specifically the timer calls a function (checkForUpdates) and if an update occurs, it sends a Notification, which is listened for:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateTable:)
name:@"ethernetStatusChanged"
object:nil];
The problem is when the notification fires, and we enter into updateTable, enabledCheckbox is a valid pointer, and powerConnectedLabel is a valid pointer, but ethernetAdaptorsTable is nil. It wasn't nil when we called updateTable via windowDidLoad, so I know it's got an appropriate 'Reference Outlet' (at least, I'm pretty sure - I'm a little confused between the difference of an "Object" in IB and "File's Owner"). But I don't know while it would be nil but the other two wouldn't.