What am I doing incorrectly with this statement? currentRow is a NSIndexPath
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row && currentRow?.row == 5 {
return 300
}
return 70
The error I get is:
Type 'Int' does not conform to protocol 'BooleanType'
If you want to check, if your currentRow and indexPath are both 5
you can't use an if-statement like that. Change it to:
if indexPath.row == currentRow?.row && currentRow == 5 {
or:
if indexPath.row == 5 && currentRow?.row == 5 {
If you want to check if indexPath
is nil
check if the indexPath is 0
if indexPath.row != 0 && currentRow?.row == 5 {
This happens because you are trying to check a non-optional indexPath.row
for being set.
If you would like to check indexPath.row
for zero, add an explicit check:
if indexPath.row != 0 && currentRow?.row == 5 {
return 300
}
Unlike Objective-C, which lets you do nil
and zero checks without an explicit condition, Swift expects an explicit condition, or performs the check using BooleanType
protocol implemented by optional types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With