加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

二进制运算符不能应用于int和int类型的操作数?斯威夫特3

发布时间:2020-12-14 05:47:33 所属栏目:百科 来源:网络整理
导读:我是快速的新手,我试了几个小时这个问题.在我的代码下面: /* [1] error in this line */if filteredCustomReqList != nil { for i in 0..filteredCustomReqList?.count { tempObj = filteredCustomReqList[i] as! [AnyHashable: Any] bezeichString = tempO
我是快速的新手,我试了几个小时这个问题.在我的代码下面:
/* [1] error in this line */if filteredCustomReqList != nil {
        for i in 0..<filteredCustomReqList?.count {
            tempObj = filteredCustomReqList[i] as! [AnyHashable: Any]
            bezeichString = tempObj?["bezeich"] as! String


            specialRequestLabel.text = ("(filteredString),(bezeichString!)")
            print (bezeichString!)
        }
}

错误说:

binary operator cannot be applied to operands of type int and int?

其中:

var filteredCustomReqList: [Any]? /* = [Any]() */

如果我使用var filteredCustomReqList:[Any] = [Any]()错误消失但我的if条件总是为真.如何解决此问题?我读过this,但与我的情况不一样(它的int和CGFloat).

任何答案和消息都会对我有所帮助.提前致谢

如果要解包filteredCustomReqList可选变量,可以使用Optional Binding.
var filteredCustomReqList: [Any]?

if let filteredCustomReqList = filteredCustomReqList {
    for i in 0..<filteredCustomReqList.count {
        tempObj = filteredCustomReqList[i] as! [AnyHashable: Any]
        bezeichString = tempObj?["bezeich"] as! String

        specialRequestLabel.text = ("(filteredString),(bezeichString!)")
        print (bezeichString!)
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读