任何人都可以帮助我,告诉我为什么我会在第2行得到错误?
消息框也说:
登入 致命错误:在展开Optional值时意外发现nil (lldb)
@IBAction func done(sender: UIBarButtonItem) {
if isSignIn == false {
//Register code
//Checking for empty boxes
if self.username.text == "" || self.password.text == "" || self.riderDriverSelect.selectedSegmentIndex == -1 {
//Red Border color for missing fields
if self.username.text == "" {
self.username.layer.borderColor = UIColor.redColor().CGColor
self.username.layer.borderWidth = 1.0
}
if self.password.text == "" {
self.password.layer.borderColor = UIColor.redColor().CGColor
self.password.layer.borderWidth = 1.0
}
if self.riderDriverSelect.selectedSegmentIndex == -1 {
self.riderDriverSelect.layer.borderColor = UIColor.redColor().CGColor
self.riderDriverSelect.layer.borderWidth = 1.0
self.showAlert("Missing field required", message: "Fill in or select missing fields in red")
}
}else{
答案 0 :(得分:1)
有1个字符串两个bool,两个bool都是!不得不改变isSignIn Bool?解决了这个问题
var buttonTitlePressed:String? var isSignIn:Bool? var isUser:Bool!