(Swift) PrepareForSegue: fatal error: unexpectedly found nil while unwrapping an Optional value

后端 未结 5 2022
Happy的楠姐
Happy的楠姐 2020-12-16 01:52

DetailViewController:

    @IBOutlet var selectedBundesland: UILabel!

TableViewController:

    override func prepareForSegue         


        
5条回答
  •  忘掉有多难
    2020-12-16 02:36

    Recently had this problem. The problem was that I had dragged the segue from a specific object from my current view controller to the destination view controller - do not do this if you want to pass values.

    Instead drag it from the yellow block at the top of the window to the destination view controller. Then name the segue appropriately.

    Then use the if (segue.identifier == "BackToCalculator") to assign the value as you are currently. All should work out!

提交回复
热议问题