Skip to content

Instantly share code, notes, and snippets.

@AppleBetas
Last active February 7, 2019 23:11
Show Gist options
  • Save AppleBetas/ac3f18c1769841d5555041abc73a5c59 to your computer and use it in GitHub Desktop.
Save AppleBetas/ac3f18c1769841d5555041abc73a5c59 to your computer and use it in GitHub Desktop.
NSAlert+QuickAlert.swift - A Swift NSAlert extension to quickly show alerts (macOS)
//
// NSAlert+QuickAlert.swift
//
// Created by AppleBetas on 2016-10-24.
// Copyright © 2016 AppleBetas. All rights reserved.
//
import Cocoa
extension NSAlert {
static func showAlert(title: String?, message: String?, style: NSAlertStyle = .informational) {
let alert = NSAlert()
if let title = title {
alert.messageText = title
}
if let message = message {
alert.informativeText = message
}
alert.alertStyle = style
alert.runModal()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment