swift 广播
2016-12-12 本文已影响135人
旅途开发者
//设置广播
let noT = NSNotification.Name(rawValue: "NotFicationName")
let dic = ["key":"value"]
NotificationCenter.default.post(name: noT, object: nil, userInfo:dic)
//创建广播中心接收广播
let name1 = NSNotification.Name(rawValue:"NotFicationName")
NotificationCenter.default.addObserver(self, selector: #selector(BaseOneController.notfifica(sender:)), name: name1, object: nil)
func notfifica(sender:NSNotification) {
print("接收广播成功")
let dic = sender.userInfo
let va = dic?["key"]
print("\(va)")
}