NSAlert

1
2
3
4
5
6
7
8
9
10
11
12
13
NSAlert *alert = [[NSAlert alloc] init];
    [alert addButtonWithTitle:@"Continue"];
    [alert addButtonWithTitle:@"Cancel"];
    [alert setMessageText:@"Alert"];
    [alert setInformativeText:@"content"];
    [alert setAlertStyle:NSWarningAlertStyle];
    [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
        if (returnCode == NSAlertFirstButtonReturn) {
            [[NSApplication sharedApplication] replyToApplicationShouldTerminate:YES];
        } else {
            [[NSApplication sharedApplication] replyToApplicationShouldTerminate:NO];
        }
    }];