I want to do as my question states. I've copied code on the subject and pasted it to playground, but each time, after the paste, xcode/playground locks up xcode which requires a reboot. I'm running the latest version of xCode and OS XI, and 've copied several versions of this,. All lock up xcode. The lastest attempt follows:
func dialogOKCancel(question: String, text: String) -> Bool {
let myPopup: NSAlert = NSAlert()
myPopup.messageText = question
myPopup.informativeText = text
myPopup.alertStyle = NSAlertStyle.warning
myPopup.addButton(withTitle: "OK")
myPopup.addButton(withTitle: "Cancel")
return myPopup.runModal() == NSAlertFirstButtonReturn
}
I plan to alert the application users of an input error, so they can correct it. In this mode, I'll delete the line to show the Cancel button.
What do I need to do to make this work?