首先,必须在类声明中指定协议,如下所示:
class MyClass: NSUserNotificationCenterDelegate
实现将如下所示:
// NSUserNotificationCenterDelegate implementationfunc 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}
当然,你必须设置委托。例如:
NSUserNotificationCenter.defaultUserNotificationCenter().delegate = self;总结
以上是内存溢出为你收集整理的代理在swift?全部内容,希望文章能够帮你解决代理在swift?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)