awakeFromNib gets called twice and outlets inside viewcontroller are not set <p>I am trying to build a menubar application for OSX. I have a AppDelegate, a Storyboard and a ViewController. The storyboard contains a application scene with the AppDelegate. The AppDelegate sets up the whole view hierarchy. Inside the AppDelegate I define a NSPopover with a ContentViewController(My ViewController). In order to set the ContentViewController I load the ViewController from the storyboard with the following code:</p> <pre><code> NSStoryboard*board=[NSStoryboard storyboardWithName:@"Main" bundle:nil]; _ruleView.contentViewController=[board instantiateControllerWithIdentifier:@"egm"]; </code></pre> <p>When I use the debugger to examine the awakeFromNib method the outlets inside the ViewController are not set why? The next problem is when the NSStatusItem is clicked it shows the NSPopover and the NSPopover calls the awakeFromNib inside my ViewController again and then my application crashes. Here is the code of the AppDelegate:</p> <pre><code>#import "AppDelegate.h" #import "ViewController.h" @interface AppDelegate() { NSStatusItem*_statusItem; NSPopover*_ruleView; } -(void)statusItemButtonPressed:(id)sender; -(void)openPopupWindow; -(void)closePopupWindow; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { } -(id)init { self=[super init]; if(self) { _ruleView=[[NSPopover alloc] init]; NSStoryboard*board=[NSStoryboard storyboardWithName:@"Main" bundle:nil]; _ruleView.contentViewController=[board instantiateControllerWithIdentifier:@"egm"]; _statusItem=[[NSStatusBar systemStatusBar] statusItemWithLength:24]; _statusItem.button.title=@"EG"; _statusItem.button.action=@selector(statusItemButtonPressed:); } return self; } -(void)statusItemButtonPressed:(id)sender { if(!_ruleView.shown) { [self openPopupWindow]; } else { [self closePopupWindow]; } } -(void)openPopupWindow{ [_ruleView showRelativeToRect:NSZeroRect ofView:_statusItem.button preferredEdge:NSMinYEdge]; } -(void)closePopupWindow{ [_ruleView close]; } - (void)applicationWillTerminate:(NSNotification *)aNotification { // Insert code here to tear down your application } </code></pre>