可选类型“Bool”不能用作布尔值;改为测试 '!=nil'
![enter image description here](https://i.stack.imgur.com/KeiNk.jpg)
一开始我遇到了一个错误if,通过替换 if 条件 (after
), the 第二个 if 条件从来没有跑过。任何想法?
Before:
if(userEmail?.isEmpty || userPassword?.isEmpty || userRepeatPassword?.isEmpty){
displayMyAlertMessage("All fields are required")
return
}
if(userPassword != userRepeatPassword){
displayMyAlertMessage("Passwords do not match.")
}
After:
if(userEmail != nil || userPassword != nil || userRepeatPassword != nil){
displayMyAlertMessage("All fields are required")
return
}
if(userPassword != userRepeatPassword){
displayMyAlertMessage("Passwords do not match.")
}
你需要用它包裹它!
代替?
.
这将解决错误消息:
if (username!.isEmpty) .....
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)