Here is my swift script which runs without errors, however, does nothing. I would expect it to display a notification in the notification center.
#!/usr/bin/env swift
import Foundation
let notification = NSUserNotification()
notification.title = "Hello"
let notificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
class MyNotificationDelegate: NSObject, NSUserNotificationCenterDelegate
{
func userNotificationCenter(center: NSUserNotificationCenter,
shouldPresentNotification notification: NSUserNotification) -> Bool {
return true
}
}
notificationCenter.delegate = MyNotificationDelegate()
notificationCenter.deliverNotification(notification)
Can someone explain why this code snippet runs as expected from a playground (displays a Notification) but does nothing, when executed as script from a terminal.