我想显示来自Swift脚本的系统警报或通知。例如,如果Desktop文件夹中有超过30个文件,我希望看到任何类型的通知。我怎么能这样做?
答案 0 :(得分:-1)
要发送本地通知,我认为你只需要使用它:
func showNotification() -> Void {
var notification = NSUserNotification()
notification.title = "Test from Swift"
notification.informativeText = "The body of this Swift notification"
notification.soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter.default.deliver(notification)
}