创建通知中心 设置监听方法 设置通知的名字 NotificationCenter.default.addObserver(self, selector: #selector(refuslt), name: NSNotification.Name(rawValue:"notification"), object: nil) 实现通知监听方法 @objc func refuslt(){ } 点击发送通知进行 NotificationCenter.default.post(name: NSNotification.Name("notification"), object: nil) 最后要记得移除通知 deinit { /// 移除通知 NotificationCenter.default.removeObserver(self) }
swift5 Notification
最新推荐文章于 2022-12-04 12:39:10 发布