Newbie question: how connect WindowController and menu events

Discussion in 'Mac Programming' started by ssawgift, Apr 11, 2012.

  1. macrumors newbie

    Mar 23, 2012
    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?
  2. macrumors 68030

    Oct 19, 2011
    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.
  3. thread starter macrumors newbie

    Mar 23, 2012
    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?

Share This Page