iOS Textfields to variables: Thread 1 SIGABRT crash

纵然是瞬间 提交于 2019-12-12 00:51:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!