title: Modal Window in Cocoa
body: <p>I'm trying to create a custom modal window and here is the code I have so far:</p>
  
  <pre><code>NSWindowController *modalSheet = [[NSWindowController alloc]
  initWithWindowNibName:@"MyCustomWindow" owner:self];
  
  [NSApp beginSheet:[modalSheet window]
   modalForWindow:[self windowForSheet]
    modalDelegate:nil
   didEndSelector:nil
      contextInfo:nil];
  </code></pre>
  
  <p>The window pops up fine but it's not modal e.g. you can still do things to the parent window where the requests come from. This method is called from an NSDocument object.</p>
  
  <p>I've tried to read: <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCustomSheets.html" rel="nofollow">Using Custom Sheets</a></p>
  
  <p>However i'm not sure what <code>myCustomSheet</code> is as it's not declared anywhere. I assume it's an <code>NSWindow</code> instance variable.</p>
  
  <p>I just can't understand why it's not modal. Any help would be much appreciated. Thanks</p>