cannot be used as a boolean

来源:互联网 发布:白城广逸网络地点 编辑:程序博客网 时间:2024/04/30 21:26

 Optional type '@lvalue ' cannot be used as a boolean; test for '!= nil' instead

With optional booleans it's needed to make the check explicit:

if boolean == true {    ...}

Otherwise you can unwrap the optional:

if boolean! {    ...}

0 0
原创粉丝点击