chenzhao

  • java
  • iOS
  • IT
知识积累
不积跬步无以至千里
  1. 首页
  2. iOS
  3. 正文

IOS 通知

2016年 10月 18日 149点热度 0人点赞 0条评论

ios 的通知

swift2.3

NSNotificationCenter.defaultCenter().postNotificationName("HomRefresh", object: data)

NSNotificationCenter.defaultCenter().addObserver(self, selector: "homeRefresh:", name: "HomRefresh", object: nil)//接受消息


func homeRefresh(Notification:NSNotification){
        // 传递的各种类型的数据
        let data = Notification.object as XX


    }

swift 3 里面写法变了 更新下写法

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "namexxx"), object: "数据", userInfo: nil)



NotificationCenter.default.addObserver(self, selector: #selector(self.collcetNotifiaction(_:)), name: NSNotification.Name(rawValue:VideoCollectMessage), object: nil)


    /// 收藏 消息接受
    func collcetNotifiaction(_ sender:Notification)  {
         let cell = self.tableView.cellForRow(at: IndexPath(row: 0, section: 2)) as? VideoNewPageOtherViewMenuCell
        if cell != nil{
            DispatchQueue.main.async {
                cell!.setMenuBtnStatus(3, status: true)
            }
           
        }
    }

标签: 暂无
最后更新:2022年 11月 11日

陈昭

IT 程序员

打赏 点赞
< 上一篇
下一篇 >

文章评论

您需要 登录 之后才可以评论

COPYRIGHT © 2022 chenzhao. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang