问题
I am trying to input information in a textfield and then store the information that is typed out as a variable, to be used in a string. For some reason it crashes whenever I click on the next textfield after the first, or the third after the second. Here is what I have.
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!
}
}
来源:https://stackoverflow.com/questions/51051241/ios-textfields-to-variables-thread-1-sigabrt-crash