I have the following code which expects to show alert as sheet in AppDelegate.m.
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
    if ([self.socket.inputStream streamStatus] == 2) {
        NSStoryboard *storyBoard = [NSStoryboard storyboardWithName:@"Main" bundle:nil];
        NSWindowController *mainWindowController = [storyBoard instantiateControllerWithIdentifier:@"MainWindow"];
        NSAlert *alert = [[NSAlert alloc] init];
        [alert addButtonWithTitle:@"OK"];
        [alert setMessageText:NSLocalizedString(@"Warning", @"Warning")];
        [alert setInformativeText:NSLocalizedString(@"Disconnect before quit this app!!", @"Disconnet before quit")];
        [alert beginSheetModalForWindow:mainWindowController.window completionHandler:^(NSModalResponse returnCode) {
        }];
        return NO;
    } else {
        return YES;
    }
}
But unfortunately, the result alert does not shown as sheet. Like the screenshot.
I can't understand why. And would like to know how can I show alert as sheet. Please help me!!

                        
It worked for me. I don't know much about.
May be it is because of the part
beginSheetModalForWindow:In your question, it seems that
beginSheetModalForWindow:mainWindowController.windowI changed it from
mainWindowController.windowtoself.view.windowand it worked, as it is given below:May be it will help i think.