Note that there are some explanatory texts on larger screens.

plurals
  1. POOSX - Cocoa - Exception when closing a sheet
    primarykey
    data
    text
    <p>I am playing with using a sheet in my app.</p> <p>I have a little test project setup to find my way.</p> <p>I did have this code working:</p> <pre><code>- (IBAction)activateSheet:(id)sender { if (!_sheet) [NSBundle loadNibNamed:@"Sheet" owner:self]; [NSApp beginSheet:self.sheet modalForWindow:[[NSApp delegate] window] modalDelegate:self didEndSelector:NULL contextInfo:NULL]; } </code></pre> <p>but the loadNibNamed method is deprecated.</p> <p>So I substitute this:</p> <pre><code>- (IBAction)activateSheet:(id)sender { if (!_sheet) NSLog(@"1"); [[NSBundle mainBundle] loadNibNamed:@"Sheet" owner:self topLevelObjects:nil]; [NSApp beginSheet:self.sheet modalForWindow: [[NSApp delegate] window] modalDelegate:self didEndSelector:NULL contextInfo:NULL]; } </code></pre> <p>The sheet opens fine. But if I press save or cancel, I get a EXC_BAD_ACCESS exception:</p> <pre><code>int main(int argc, const char * argv[]) { return NSApplicationMain(argc, argv); } </code></pre> <p>UPDATE - This is a breeze with 10.9:</p> <pre><code>- (IBAction)activateSheet:(id)sender { if (!_sheet) [[NSBundle mainBundle] loadNibNamed:@"Sheet" owner:self topLevelObjects:nil]; [[[NSApp delegate] window] beginSheet:self.sheet completionHandler:nil]; } - (void)endSheet:(NSWindow *)sheetWindow returnCode:(NSModalResponse)returnCode { [sheetWindow orderOut:self]; } - (IBAction)save:(id)sender { [self doSave]; result = 1; [self endSheet:self.sheet returnCode:result]; } - (IBAction)cancel:(id)sender { result = 0; [self endSheet:self.sheet returnCode:result]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload