How do I write an NSAlert in latest swift?
<p>I'm trying to write this alert:</p>

<pre><code>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) -&gt; Void in
            print ("returnCode: ", returnCode)
        }
</code></pre>

<p>but I get the dreaded <code>unexpectedly found nil while unwrapping an Optional value</code> message on the line <code>alert.beginSheetModal</code></p>

<p>Please tell me what I'm doing wrong.</p>

<p>Thanks</p>