我正在尝试编写此警报:
func alertUser() {
let alert = NSAlert()
alert.messageText = "message 1"
alert.informativeText = "info1"
alert.informativeText = "info2"
alert.addButton(withTitle: "NO")
alert.addButton(withTitle: "YES")
alert.beginSheetModal(for: self.view.window!) { (returnCode: NSModalResponse) -> Void in
print ("returnCode: ", returnCode)
}
但我收到了一条可怕的unexpectedly found nil while unwrapping an Optional value
消息alert.beginSheetModal
请告诉我我做错了什么。
谢谢