发现意外的 segue 错误 nil

unexpected segue error found nil

按下主页按钮时出现此错误:线程 1:致命错误:意外的 Segue 标识符;无

这是我的代码:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    super.prepare(for: segue, sender: sender)

    switch(segue.identifier ?? "")
    {

    case "AddItem":
        os_log("Adding a new day.", log: OSLog.default, type: .debug)

    case "ShowDetail":
        guard let newDayDetailController = segue.destination as? newDayController else {
            fatalError("Unexpected destination: \(segue.destination)")
        }

        guard let selectednewDayCell = sender as? newDayTableViewCell else {
            fatalError("Unexpected sender: \(String(describing: sender))")
        }

        guard let indexPath = tableView.indexPath(for: selectednewDayCell) else {
            fatalError("The selected cell is not being displayed by the table")
        }

        let selectedDay = days[indexPath.row]
        newDayDetailController.day = selectedDay

    case "toMenu":
        os_log("Back to main menu", log: OSLog.default, type: .debug)


    if segue.identifier == "sendData"
    {
        let VC = segue.destination as! HomeViewController

        VC.data = totalDays!

    }

    default:
    fatalError("Unexpected Segue Identifier; \(String(describing: segue.identifier))")
    }
}


//MARK: Actions

@IBAction func menuButton(_ sender: Any) {

    performSegue(withIdentifier: "sendData", sender: self)

}

有人帮帮我吗?

确保在故事板的属性检查器中设置 segue 标识符

显然你的 switch 陈述适用于 default 案例。