更新时间:2022-12-07 19:02:49
必须解开可选项.您必须检查它或像您一样强行拆开包装.想象一下将可选值作为放置值的方框.在访问它之前,需要将其放入.
Optionals must be unwrapped. You must check for it or force unwrap as you do. Imagine the optional as a box where you put a value. Before you can access it, you need to put it out.
if let name = nameTextField.text {
nameLabel.text = "Hello, \(name)"
}