代理在swift?

代理在swift?,第1张

概述如何做一个委托,即NSUserNotificationCenterDelegate在swift? 它与obj-c没有什么不同。 首先,必须在类声明中指定协议,如下所示: class MyClass: NSUserNotificationCenterDelegate 实现将如下所示: // NSUserNotificationCenterDelegate implementationfunc us 如何做一个委托,即NSUserNotificationCenterDelegate在swift? 它与obj-c没有什么不同。
首先,必须在类声明中指定协议,如下所示:
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?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1062174.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存