Swift 3.0 通知的注册,监听及销毁

前端之家收集整理的这篇文章主要介绍了Swift 3.0 通知的注册,监听及销毁前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

注册通知

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "AuthSuccessNotification"),object: nil)

监听通知

NotificationCenter.default.addObserver(self,selector:#selector(ViewController.pageJump),name: NSNotification.Name(rawValue: "AuthSuccessNotification"),object: nil)

销毁通知

deinit {
        NotificationCenter.default.removeObserver(self)
}
  1. deallco方法改成了deinit
  2. 一定要注意线程问题
原文链接:https://www.f2er.com/swift/322733.html

猜你在找的Swift相关文章