Question

I'm loading a sheet into my main .xib, the sheet is a panel and I have no problem displaying the sheet or closing it but when I close it I am getting an error message:

2012-02-21 11:10:12.142 CollectionTest2[23277:10b] *** -
[AppController customSheetDidClose:returnCode:contextInfo:]: unrecognized selector sent to instance 0x359c00

Here is my code:

/*Sheet Methods*/

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

    [NSApp beginSheet: panFilenameEditor modalForWindow: window modalDelegate: self didEndSelector: @selector(customSheetDidClose:returnCode:contextInfo:) contextInfo: nil];
}

- (IBAction)closeCustomSheet:(id)sender {

    [panFilenameEditor orderOut:self];
    [NSApp endSheet:panFilenameEditor];
}

- (void) customSheetDidClose   { 

    NSLog(@"sheet did close");
} 
Was it helpful?

Solution

In your showCustomSheet method, you tell the sheet to call the selector customSheetDidClose:returnCode:contextInfo: on your app controller. But there is no such method.

There are two solutions:

  • Either pass @selector(customSheetDidClose) in your call to beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:.
  • Or rename your customSheetDidCloseMethod to - (void)customSheetDidClose:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top