【发布时间】:2019-12-06 05:52:59
【问题描述】:
我是 swift 新手,我已经尝试了几个小时这个问题。在我的代码下方:
if filteredCustomReqList != nil { /* [1] error in this line */
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)。
任何回答和建议都会对我有所帮助。提前致谢
【问题讨论】:
-
错误似乎出现在
for行,而不是if行,对吗?
标签: swift