这是我在 Xcode
中的代码...但是我得到的条件绑定(bind)的初始化程序必须具有可选类型,而不是“Wires_Cables_Details_Menu”。任何解决方案
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
if let formulation_type_a_menu =
Wires_Cables_Category_MasterData.instance.getformulations_type_a()[indexPath.row]
{
performSegue(withIdentifier: "WC_Formulation_Segue", sender: formulation_type_a_menu)
}
else
{
let forumulation_type_c_menu = Wires_Cables_Category_MasterData.instance.getformulations_type_c()[indexPath.row]
performSegue(withIdentifier: "WC_Formulation_Segue", sender: forumulation_type_c_menu)
}
}
最佳答案
if let
语句中的操作不返回可选值。它永远不会是nil
,所以条件绑定(bind)不是必需的。这里有两条前进的路。您可以修改 Wires_Cables_Category_MasterData.instance
或 getformulations_type_a()
以返回可选类型,或者您可以找到一些其他条件来决定是否调用 getformulations_type_a()
或 getformulations_type_c()
不涉及条件绑定(bind)。然而,现在的错误是因为您试图用 if let
关于ios - didselectrowat Indexpath 使用两个发送者和一个公共(public) Segue 标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46997157/