title: How to connect a menu item to a custom action defined in the NSApplication delegate across nib files?
body: <p>In my Cocoa app I have two NIB/XIB files that I need to connect:</p>
  
  <ol>
  <li><p><em>MainMenu.xib</em>: contains a custom object for the NSApplication delegate object and connects it to the proper outlet in the <code>NSApplication</code> placeholder.</p></li>
  <li><p><em>ContextMenu.xib</em>: sets up an <code>NSMenu</code>; one entry is supposed to open the preferences dialog</p></li>
  </ol>
  
  <p>My custom app delegate defines an <code>IBAction</code> to bring up the Preferences window for my app.</p>
  
  <p>How can I connect the NSMenuItem (second NIB) for showing the preferences to the action defined in the application delegate (first NIB)?</p>
  
  <p>The <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW32" rel="nofollow">Docs</a> say this is supposed to be easy, but they fail to mention how exactly to do this in Interface Builder:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>Thanks for any pointers!</p>