我想计算一下登录按钮被点击了多少次。如果用户名和密码字段为空,并且单击了登录按钮,我希望计数递增1。
在这个IBAction函数中,我不能把"count“作为inout参数,我该如何完成这个任务呢?
@IBAction func loginButtonAction(_ sender: Any) {
var count : Int = 0
if (Username.text!.isEmpty || Password.text!.isEmpty ) {
let myAlert = UIAlertController(title: "Alert", message: "All fields are required to fill in", preferredStyle: UIAlertController.Style.alert)
let OkAction = UIAlertAction(title: "Ok", style: UIAlertAction.Style.default, handler: nil)
myAlert.addAction(OkAction)
self.present(myAlert,animated: true, completion: nil)
return
}
https://stackoverflow.com/questions/56561126
复制相似问题