本文介绍了代表们迅速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
推荐答案
与obj-c没有什么区别。
首先,您必须在类声明中指定协议,如下所示:
It is not that different from obj-c.First, you have to specify the protocol in your class declaration, like following:
class MyClass: NSUserNotificationCenterDelegate
实现将如下所示:
// NSUserNotificationCenterDelegate implementation
func userNotificationCenter(center: NSUserNotificationCenter, didDeliverNotification notification: NSUserNotification) {
//implementation
}
func userNotificationCenter(center: NSUserNotificationCenter, didActivateNotification notification: NSUserNotification) {
//implementation
}
func userNotificationCenter(center: NSUserNotificationCenter, shouldPresentNotification notification: NSUserNotification) -> Bool {
//implementation
return true
}
当然,你必须设置代表。例如:
Of course, you have to set the delegate. For example:
NSUserNotificationCenter.defaultUserNotificationCenter().delegate = self;
这篇关于代表们迅速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!