gpt4 book ai didi

Swift 一元运算符 '!' 不能应用于类型为 'OLVideoCell' 的操作数

转载 作者:行者123 更新时间:2023-11-28 12:49:36 25 4
gpt4 key购买 nike

  //This is in the UITableViewCell class method
class func videoCellWithTableView(tableview:UITableView) -> OLVideoCell{

var cell = tableview .dequeueReusableCellWithIdentifier("OLVideoCell") as! OLVideoCell

// “!cell” Why you will be prompted “ Unary operator '!' cannot be applied to an operand of type 'OLVideoCell'”

if !cell {

cell = OLVideoCell(style: .Default, reuseIdentifier: "OLVideoCell")

cell.selectionStyle = .None

}
return cell
}

最佳答案

if cell == nil,if语句中任何条件的值必须有一个符合BooleanType协议(protocol)的类型。条件也可以是可选的绑定(bind)声明。

关于Swift 一元运算符 '!' 不能应用于类型为 'OLVideoCell' 的操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36883450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com