Question

In my Cocoa app I have two NIB/XIB files that I need to connect:

  1. MainMenu.xib: contains a custom object for the NSApplication delegate object and connects it to the proper outlet in the NSApplication placeholder.

  2. ContextMenu.xib: sets up an NSMenu; one entry is supposed to open the preferences dialog

My custom app delegate defines an IBAction to bring up the Preferences window for my app.

How can I connect the NSMenuItem (second NIB) for showing the preferences to the action defined in the application delegate (first NIB)?

The Docs say this is supposed to be easy, but they fail to mention how exactly to do this in Interface Builder:

If the menu item refers to an application-level command, you can implement that command directly in the application delegate or just have the delegate forward the message to the appropriate object elsewhere in your application.

I somehow need to access the app delegate in the second NIB, tell Interface Builder that it is of my custom class (so it knows about the custom IBAction), and connect it to the action of the menu item.

Thanks for any pointers!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top