import UIKit
class FirstViewController: UIViewController {
@IBOutlet weak var textFiled: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func pressDoneButton(_ sender: UIBarButtonItem) {
performSegue(withIdentifier: "showSecondVC", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showSecondVC" {
let secondVC = segue.destination as! SecondViewController
secondVC.textLabel.text = textFiled.text!
}
}
}
The error is : thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
But I'm sure textFiled.text!
contains a value.
Why the error comes?