Swift 3 - Prepare Segue

前端 未结 3 2131
终归单人心
终归单人心 2021-01-14 00:06

I have 3 scenes in my storyboard. My initial View Controller is a Navigation Controller, then there is a relationship root view controller to a UI ViewController (view contr

3条回答
  •  半阙折子戏
    2021-01-14 00:46

    Replace your code with the following, it will not crash at least.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
            if segue.identifier == "HistorySegue" {
                if let viewController = segue.destination as? HistoryController {
                  if(barcodeInt != nil){
                    viewController.detailItem = barcodeInt as AnyObject
                   }
                }
            }
        }
    

提交回复
热议问题