Search code examples
cocoamodal-dialogcocoa-sheet

Modal session requires modal window


I'm trying to open a window like a sheet so that it appears down below the toolbar. I've used the O'Reilly tutorial to do this. However, I can get past this error: Modal session requires modal window.

The window loads as a window if I have "Visible At Launch" checked.

Whether it is checked or not I get the "Modal session requires modal window" error.

I have a Window.xib, ProgressModal.xib.

In the Window implementation file I use:

-(IBAction)loadProgress:(id)sender{
    [self progressStatus:progressWindow];
}

- (void)progressStatus:(NSWindow *)window {

    [NSApp beginSheet: window
       modalForWindow: mainWindow
        modalDelegate: nil
       didEndSelector: nil
          contextInfo: nil];
    [NSApp runModalForWindow: window];
    [NSApp endSheet: window];
    [window orderOut: self];

}

- (IBAction)cancelProgressScrollView:(id)sender {
    [NSApp stopModal];
}

I may have the ProgressModal.xib setup wrong. I have an NSObject in it that has "Window" as its class. All the connections are made through that.

But again, it loads the window just won't load it as a modal.

Any ideas?


Solution

  • As I stated above, I dragged an object over in the progressModal window and made my connections through that. What I should have done was made the File's owner my Window class. Changing that fixed the problem.

    I got this from http://www.youtube.com/watch?v=QBkO6TD-fWA