检查文本字段是否为空导致Swift 2中的错误 [英] Checking if text fields are empty cause error in Swift 2

查看:100
本文介绍了检查文本字段是否为空导致Swift 2中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检查文本框是否没有值.

I am trying to check if a textbox has no value.

当我这样做时:

if(userEmail?.isEmpty || userPassword?.isEmpty || userPasswordRepeat?.isEmpty)  

我收到以下错误

我尝试添加?"在".isEmpty"之前,但错误不会消失

I tried adding "?" before the ".isEmpty" but the error won't go away

有什么想法吗?

推荐答案

尝试一下....

if txtEmail.text?.isEmpty == true || txtPassword.text?.isEmpty == true || txtRePassword.text?.isEmpty == true{
        print("true")
}

这篇关于检查文本字段是否为空导致Swift 2中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆