An overview of the
NSAlert is a prompt or warning popup in macOS applications that allows you to specify prompt text, button titles, custom ICONS, and more. The basic display style is as follows:
The specific implementation
Let alert = NSAlert() // set Message alert. MessageText = "Are you sure you want to remove your marked notes?" ; // set informative text alert.informativeText = "Marked ontes will also be removed on other devices signed into your account". //set accessory View alert.accessory = NSView() //help alert.showsHelp = true; alert.delegete = self; func alertShowHelp(_ alert:NSAlert) ->Bool{} //suppression checkbox alert.showsSuppressionButton = true; alert.suppressionButton = cutomBtn; //response button alert.addButton(withTitle:"Cancel"); // Set type alert.alertstyle = nsalert.style. Warning // Pop-up box func beginSheetModal(for sheetWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil)Copy the code
Pop-up play box there is a way to open func runModal () – > NSApplication. ModalResponse this way is a popup modal window, also is the need to close the current bounced, can the other Windows.