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)
}
}
}
文章评论