美文网首页
NSNotification

NSNotification

作者: Alan龙马 | 来源:发表于2019-05-21 09:05 被阅读0次
//发送通知
NotificationCenter.default.post(name: NSNotification.Name(rawValue: kMJNewChatBadgeNotification), object: nil, userInfo: ["count": num])

//接收通知,记得要销毁通知
NotificationCenter.default.addObserver(self, selector: #selector(showNewBadgeNumber(_:)), name: NSNotification.Name(rawValue:kMJNewChatBadgeNotification), object: nil)

@objc func showNewBadgeNumber(_ sender: Notification?) {
    
    if let count = sender?.userInfo?["count"] as? Int{
        
    }
}
#pragma mark ************** 销毁通知
deinit {
    NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: kMJNewChatNotification), object: nil)
  
}

相关文章

  • NSNotification

    发通知 NSNotification *deleteMyCommemtN =[NSNotification not...

  • 通知使用

    创建对象 NSNotification *notification =[NSNotification notifi...

  • iOS通知中心

    有关的类 NSNotification NSNotificationCenter NSNotification N...

  • 通知中心(NSNotificationCenter)总结

    一、简介 1. NSNotification 理解 NSNotification@property (readon...

  • 推送通知-本地推送

    iOS推送通知 注意:这里说的推送通知跟NSNotification有所区别 NSNotification是抽象的...

  • NSNotification是同步还是异步?和delegate相

    1、NSNotification是同步还是异步?默认情况下,创建的NSNotification是同步的,发布通知 ...

  • iOS 推送后台语音播报

    推送通知 注意:这里说的推送通知跟NSNotification有所区别 NSNotification是抽象的,不可...

  • iOS本地推送

    1. 推送通知简介 1.1: 这里说的推送通知跟NSNotification有所区别 NSNotification...

  • NSNotification

    当你定义你自己的 NSNotification的时候你应该把你的通知的名字定义为一个字符串常量,就像你暴露给其他类...

  • NSNotification

    通常我们在 iOS 中发生什么事件时该做什么是由 Delegate 实现的,例如 View 加载完后会触发 vie...

网友评论

      本文标题:NSNotification

      本文链接:https://www.haomeiwen.com/subject/dptdzqtx.html