在Swift 4中我试图将UITextField的文本长度与最小长度进行比较:
if textFieldPassword.text?.count >= 8 {
}
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
Binary operator '>=' cannot be applied to operands of type 'String.IndexDistance?' (aka 'Optional<Int>') and 'Int'
Run Code Online (Sandbox Code Playgroud)
具有讽刺意味的是
textFieldPassword.text?.count == 8
Run Code Online (Sandbox Code Playgroud)
有人能帮助我吗?
swift ×1