gpt4 book ai didi

ios - 我无法发布通知

转载 作者:行者123 更新时间:2023-11-29 00:12:30 24 4
gpt4 key购买 nike

我已经搜索了 stack over flow 和所有网站,但无法发布通知,我需要将数据从这个类传递到另一个类,我需要发送 bool 值进行验证,谁能帮助我如何传递 bool 值?

这是它的代码

        radioSelected = false
NotificationCenter.default.addObserver(self, selector: #selector(paymentRadioEnable(n:)), name: NSNotification.Name.init(rawValue: "notification"), object: nil)
self.shippingmethodURL()
shippingTableView.delegate = self
shippingTableView.dataSource = self
shippingTableView.rowHeight = UITableViewAutomaticDimension
shippingTableView.estimatedRowHeight = shippingTableView.rowHeight
// Initialization code
}
func paymentRadioEnable(n:NSNotification){

}
func paymentRadioAction(button : KGRadioButton) {
_ = button.center
let centralPoint = button.superview?.convert(button.center, to:self.shippingTableView)
let indexPath = self.shippingTableView.indexPathForRow(at: centralPoint!)
if button.isSelected {

} else{
chekIndex = indexPath
radioSelected = true
self.shippingTableView.reloadData()
}
}

这是另一个我需要将 bool 值发布到其中以进行检查的类

@IBAction func continueButtonAction(_ sender: Any) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "notification"), object: nil)
if radioSelected == false {
let radiobutton = SCLAlertView()
_ = radiobutton.showError("Warning", subTitle: "Please select shipping method", closeButtonTitle: "OK")
}else{
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let addtoCartVC = storyboard.instantiateViewController(withIdentifier: "payment") as! PaymentMethodViewController
self.navigationController?.pushViewController(addtoCartVC, animated: true)
}
}

最佳答案

您可以在发布通知时将数据发送到对象中

let data : NSDictionary = ["DataKey" : "DataValue"]

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "notification"), object: data)

发布后,您可以在通知处理程序中获取相同的数据。

关于ios - 我无法发布通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46052833/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com