我对这句话做错了什么?currentRow是一个NSIndexPath
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row && currentRow?.row == 5 {
return 300
}
return 70
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
类型'Int'不符合协议'BooleanType'
如果要检查,如果currentRow和indexPath都是5,则不能使用if语句.将其更改为:
if indexPath.row == currentRow?.row && currentRow == 5 {
Run Code Online (Sandbox Code Playgroud)
要么:
if indexPath.row == 5 && currentRow?.row == 5 {
Run Code Online (Sandbox Code Playgroud)
如果您想检查indexPath是nil检查是否indexPath是0
if indexPath.row != 0 && currentRow?.row == 5 {
Run Code Online (Sandbox Code Playgroud)