首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用IBAction按钮计算用户登录尝试次数

使用IBAction按钮计算用户登录尝试次数
EN

Stack Overflow用户
提问于 2019-06-12 19:28:05
回答 1查看 72关注 0票数 2

我想计算一下登录按钮被点击了多少次。如果用户名和密码字段为空,并且单击了登录按钮,我希望计数递增1。

在这个IBAction函数中,我不能把"count“作为inout参数,我该如何完成这个任务呢?

代码语言:javascript
复制
@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
    }
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56561126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档