logo
  • 教程列表
  • SO官方文档
  • NSNotificationCenter
    • 删除观察员
    • 添加观察者
    • 使用数据发布通知
    • 添加和删​​除名称的观察者
    • 发布通知
    • 观察通知
    • 添加使用块删除观察者
  1. StackOverflow 文档
  2. iOS 教程
  3. NSNotificationCenter
  4. 添加和删​​除名称的观察者

添加和删​​除名称的观察者

Created: November-22, 2018

// Add observer
let observer = NSNotificationCenter.defaultCenter().addObserverForName("nameOfTheNotification", object: nil, queue: nil) { (notification) in
    // Do operations with the notification in this block
}

// Remove observer
NSNotificationCenter.defaultCenter().removeObserver(observer)
  • 发布通知
  • 使用数据发布通知

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明