Fab
Fab

Reputation: 1564

ViewController reference in AppDelegate using Storyboard

I am writing a one view application based on storyboard.

I have added a toolbar, clicking on buttons messages are received into the AppDelegate.

I need to forward them to the ViewController but I am not able to get a reference to it in the AppDelegate.

How do I do that?

Upvotes: 2

Views: 1602

Answers (1)

Fab
Fab

Reputation: 1564

As simple as that:

- (void)applicationDidBecomeActive:(NSNotification *)aNotification {

   if (_viewController==nil) {
       _viewController = (ViewController *)[[NSApplication sharedApplication] mainWindow].contentViewController;
   }
}

Upvotes: 2

Related Questions