我正在尝试在文本字段中输入信息,然后将键入为变量的信息存储在字符串中。由于某种原因,当我单击第一个或第二个之后的下一个文本字段时,它会崩溃。这就是我所拥有的。
var name: String?
@IBAction func nameField(name: UITextField) {
let name = name.text
}
var contact: String?
@IBAction func contactField(contact: UITextField) {
let contact = contact.text
}
var other: String = "nothing"
@IBAction func otherField(other: UITextField) {
if other == nil {
}else{
let other = other.text!
}
}