显示来自Swift脚本的系统警报或通知
答
要发送本地通知,我想你只需要使用这样的:
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)
}
你能更精确地了解你知道什么,在哪里你就完蛋了?我想你只是创建了一个解析文件夹内容来计算文件数量的方法。然后,如果此数字大于30,则使用本地通知显示警报。 – Maxime
要驱动任何用户界面,您的*脚本*必须是应用程序(以利用AppKit和运行循环)。 – vadian
Maxime,我的主要问题是如何显示本地通知? –