I have a textfield and I want it to hide and show when a button is pressed, and I also want the text in the textfield to be passed to a label just underneath the textfield. I tried this :
@IBAction func myfunction(_ sender: UIButton) {
if textfield.isHidden == true{
textfield.isHidden = false
}else{
label.text = textfield.text
textfield.isHidden = true
}
}
Apparently the hidding and showing part is working but the line
label.text = textfield.text
is not. I get an error like this "Thread 1: EXC_BREAKPOINT (code=1, subcode=0x10143fb50" and in the console I have "fatal error: unexpectedly found nil while unwrapping an Optional value"
Can someone help me please.