macoscocoanswindowcocoa-sheet

beginSheet method not working for me


I have saveWindowController (NSWindowController subclass object). I use initWithWindowNibName: method to init the controller.
I set File's owner in xib to SaveWindowController. I connect delegate (from window) to File's owner and window (from controller) to NSWindow in xib file.

[NSApp beginSheet:[self.saveWindowController window] 
   modalForWindow:[self window]
    modalDelegate:nil didEndSelector:nil contextInfo:nil];

After executing this method I see modal window without titlebar and it appears not like normal sheet. It just appears in left bottom corner of first window.

Could you help me, what I'm doing wrong?


Solution

  • Do you have your SaveWindowController's window set to "Visible at Launch" in the XIB? You must uncheck that option, or your window will try to display as soon as the XIB is loaded, and will not be positioned correctly.