I have two views. The first one has a UITextView
and a button. The second has a UILabel
. When I click on the button I would like the text label of the second views to be filled with what was in the textfield
of the first view.
I did the following:
@IBAction func tapButton() {
let vc = storyboard?.instantiateViewController(identifier: "second") as! SViewController
vc.l.text = t.text
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true)
}
l is the UILabel
and t is the UITextField
. When I run this code it's telling me I am trying to unwrapped l whereas l is nil.
But why l is nil? I mean if I instantiate my second view then it should create the UILabel l and thus l is not nil?