title: Creating a Modal Dialog or Window in Cocoa Objective-C?
body: <p>I need to create an modal dialog, which is to loaded from a nib file and should be displayed on a button click in the main window.</p>
  
  <p>I can create a custom window in a nib file and load the custom dialog on button click, but it's not a modal dialog. I can switch back to the main window.</p>
  
  <p><code>MyWindowController</code> is the <code>NSWindowController</code> subclass.
  I used the code below to display my window in response to the button event:</p>
  
  <pre><code>MyWindowController *pController = [[MyWindowController alloc] 
                                     initWithWindowNibName:@"nibfilename"];
  [MyWindowController showWindow:self];
  </code></pre>