我正在开发一个快速的os x应用程序,并且我很难理解userNoticiation / didActivateNotification结构。我已经查看了文档并进行了搜索,但仍然停留在这里。如能就下列守则提供任何指导,将不胜感激:
func notify(message: String, callBack: String) {
println(message)
println(callBack)
var notification:NSUserNotification = NSUserNotification()
notification.title = "New Phone Call"
notification.informativeText = message
notification.actionButtonTitle = "Lookup"
notification.hasActionButton = true
var center:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
center.delegate = self
center.scheduleNotification(notification)
}
func notify (center: NSUserNotificationCenter, didActivateNotification notification: NSUserNotification){
center.delegate = self
println("clicked") //this does not print
}通知将按我所希望的方式显示。单击我定义的“查找”按钮将使我的应用程序在第一次点击时到达前台,但我希望处理的代码不会触发。
提前谢谢。
发布于 2014-12-11 20:45:48
将第二个'func通知‘声明更改为’可选func userNotificationCenter‘
https://stackoverflow.com/questions/27428590
复制相似问题