1
我編寫簡單的程序 我想表明在Mac OS通知X斯威夫特通知中心無法解開Optional.None
這是我的代碼
import Foundation
import Cocoa
var notification:NSUserNotification = NSUserNotification()
notification.title = "TEST"
notification.subtitle = "TTTT"
var notificationcenter:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
if(notificationcenter != nil) {
notificationcenter.scheduleNotification(notification)
}
代碼構建成功,但時停止運行代碼
fatal error: Can't unwrap Optional.None
var notificationcenter:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
我能做些什麼