我有两个IBOulets
:
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
我想检查他们的文本字段是否为空。但是,当我调用 text.isBlank 方法时,编译器显示错误 "Ambiguous reference to member 'text'"
if ChatManager.shared.isConnected() {
ChatManager.shared.disconnect()
usernameTextField.isHidden = false
passwordTextField.isHidden = false
} else {
guard usernameTextField.text.isBlank == false,
passwordTextField.text.isBlank == false else {
return
}
我还注意到 UITextfield 有 text : String?或文本(UITextRange):字符串?
最佳答案
试试这个
else {
guard usernameTextField.text.isEmpty == false,
passwordTextField.text.isEmpty == false else {
return
}
关于swift - 对成员 "text"的模糊引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45407381/