I am just not able to unwrap else
block. xCode gives me options to \"Fix it with ! and ??\", which sadly does not fix the issue either.
I get this error in xCod
Because theButton.titleLabel?.text it not unwrapped.
You can use
answerField.text = answerField.text + (theButton.titleLabel?.text ?? "")
or
if answerField.text == "0" {
answerField.text = theButton.titleLabel?.text
} else {
if let txt = theButton.titleLabel?.text {
answerField.text = answerField.text + txt
} else {
answerField.text = answerField.text
}
}