View Full Version : Newbie question: how connect WindowController and menu events

Apr 11, 2012, 11:00 PM
I'm learning XCODE proramming. Now I have simple application that has a MainWindow.xib, MainWindowController (NSWindowController).

I set MainWindow.xib's File's Ower to MainWindowController, but cannot get menu actions working. When I run the application, menu items are grayed out.

And I saw this in console:
Could not connect the action newDocument: to target of class NSApplication

What am I doing wrong?

Apr 11, 2012, 11:36 PM
The menu belongs to the app, not to the window. Programmatically they can be accessed through
[[NSApp mainMenu]delegate]

Usually you can create connections from menu items to the App delegate using the assistant editor.

Sorry, I can't help more, I struggled with this myself a few days ago.

Apr 12, 2012, 12:13 AM
I found out that I can set File's Owner of MainWindow.xib to AppDelegate.

Now the problem is how I can connect the main window to my window controller. Any ideas?

EDIT: Do I need a window controller?