更新时间:2022-06-13 23:10:45
textField的文本 是一个可选值,因为文本字段有时可能是空的。所以,使用如果让
打开变量 和 ,请确保它不是nil - 否则你的程序可能会崩溃:
The text of your textField is an optional value because a text field can sometimes be empty. So, use an if let
to unwrap the variable and make sure it's not nil — otherwise your program could crash:
if let text: String = textField.text {
textLabel.text = text
}