func tableView(_ tableView:UITableView,didSelectRowAt indexPath:IndexPath){
self.selectedIndexPath = indexPath as NSIndexPath
performSegue(withIdentifier: "toAddToChart", sender: nil)
}
open override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let indexPath = self.selectedIndexPath
let product = products[indexPath.row]
if (segue.identifier == "toAddToChart") {
if let viewController = segue.destination as? AddToOrderVC {
viewController.productName = product.productName
viewController.productCode = product.productCode
viewController.productType = product.productType
viewController.productPrice = product.productPrice
viewController.productDetails = product.productDescription
viewController.pImageUrl = product.productimageUrl
}
}
}
/当我从viweController中删除prepareForSegue函数时它会工作但是当我应用它并且在构建代码后我得到线程1:当按下另一个动作segue按钮时发出SigBArt错误信息
答案 0 :(得分:0)
何时让产品=产品[indexPath.row] 用确认标识符调出segue的一侧,它将出现错误,因此该错误是
open override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let indexPath = self.selectedIndexPath
if (segue.identifier == "toAddToChart") {
if let viewController = segue.destination as? AddToOrderVC {
let product = products[indexPath.row]
viewController.productName = product.productName
viewController.productCode = product.productCode
viewController.productType = product.productType
viewController.productPrice = product.productPrice
viewController.productDetails = product.productDescription
viewController.pImageUrl = product.productimageUrl
}
}
}