OS X Storyboard Window Content View Controller is nil

Can someone tell me why this is happening?


I have converted an OS X app to use Storyboards. Some of my NSViewControllers have an associated NSWindowController. I created a 'window content' relationship from the Window Controller to the View Controller.

I create a segue to the Window Controller. In prepareForSegue, I get the destination controller, which is the window controller, but I really want the contentViewController. However, the issue is that the contentViewController is nil. I want to do something like the following.


NSWindowController *wc = [segue destinationController];

MyViewController *mvc = (MyViewController *)wc.window.contentViewController;


But looking at wc in the debugger, its contentViewController is nil.

Accepted Reply

After sending Apple my sample problem, they made the correct assertainment that I was incorrect. The contentViewController was okay, but an ivar wasn't being set. I had to do the following in my sample project. Stupid me.


- (void)viewDidLoad {

[super viewDidLoad];

self.daText.stringValue = self.labelString ?: @"";

}

- (void)setLabelString:(NSString *)labelString {

_labelString = [labelString copy];

self.daText.stringValue = _labelString ?: @"";

>}

Replies

I'm going to file a bug report on this.

Apple wanted me to test this on OS X 10.11 seed. Since I don't have the beta version of OS X, I sent them a sample project instead.

After sending Apple my sample problem, they made the correct assertainment that I was incorrect. The contentViewController was okay, but an ivar wasn't being set. I had to do the following in my sample project. Stupid me.


- (void)viewDidLoad {

[super viewDidLoad];

self.daText.stringValue = self.labelString ?: @"";

}

- (void)setLabelString:(NSString *)labelString {

_labelString = [labelString copy];

self.daText.stringValue = _labelString ?: @"";

>}