Please help! I am trying to make an app, with the user setting their name so it can be later displayed on a label such as: Welcome, (username).
But when trying to run my code, xcode gives me an error: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value.
Here is my code:
class HomeViewController: UIViewController {
@IBOutlet weak var displayLbl: UILabel!
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var submitBtn: UIButton!
var result : String!
override func viewDidLoad() {
super.viewDidLoad()
displayLbl.text = ""
submitBtn.setTitle("Submit", for: UIControl.State.normal)
}
@IBAction func submitAction(_ sender: Any) {
result = textField.text!
displayLbl.text = "\(result!)"
}
It gives me an error on (displayLbl.text = ""), but I don't know what to do about it. Please help
Selecting any option will automatically load the page