I show the sheet in my main window. I submit a sheet using this code:
AddContactWindowController *addContact = [[AddContactWindowController alloc] initWithWindowNibName:@"AddContactWindow"];
addContact.currentViewController = myView;
self.addWindowController = addContact;
[self.view.window beginSheet: addContact.window completionHandler:^(NSModalResponse returnCode) {
NSLog(@"completionHandler called");
}];
AddContactWindowController is a subclass of NSWindowController. It has a view controller. Inside the view is a close button that calls this:
[[[self view] window] close];
This closes the window, but the executeHandler method of beginSheet is not called. This will cause me problems in the future.
Is there any special way to close the NSWindow sheet to successfully complete the completion handler? I also tried [[[self view] window] orderOut:self], but this does not work either.
Thank.
source
share