title: Cocoa: Plugin Cannot Open App Window
body: <p>I am developing an plugin for <a href="http://www.osirix-viewer.com/AboutOsiriX.html" rel="nofollow noreferrer">OsiriX</a>. </p>
  
  <p><em>In that app i have 3-4 nib files. Also in for plugin there are files (.h &amp; .m)  called PluginFilter where method called  - (long) filterImage:(NSString) menuName is present from which the plugin start execution. Now my problem is that, I have return the code to launch main window is in some other .m file and I have to call that file using the method mentioned above.</em> </p>
  
  <p>The app has multiple nib files. I have a plugin name PluginFilter called by:</p>
  
  <pre><code>- (long) filterImage:(NSString*) menuName
  </code></pre>
  
  <p>The plugin should open a window when called by this method. The code that defines the window controller is in another nib. When I call the <code>filterimage</code> method in the plugin, the window never appears.</p>
  
  <p>Here is my <code>filterImage:</code> method.</p>
  
  <pre><code>#import "XGridInOsiriXFilter.h"
  #import "MainWindowController.h"
  
  @implementation XGridInOsiriXFilter
  
  - (void) initPlugin
  {
  
  }
  
  - (long) filterImage:(NSString*) menuName
  {
  
      MainWindowController *mainWindowController = [[GridSampleMainWindowController alloc] init];
      [mainWindowController showWindow:self ];
      [mainWindowController release];
  
      return 0;
  }
  
  @end
  </code></pre>
  
  <p>Calling the method produces not warnings or errors, the window simply fails to appear. </p>