【发布时间】:2016-11-21 06:44:37
【问题描述】:
我想在 switch 中使用 if 语句,但我不断收到预期的表达式错误。如果有人能帮我解决这个问题,我将不胜感激。
switch ([ApplicationModel getApplicationType]) {
case CSApplication: {}
break;
case RAApplication:
{
if (indexPath.row == FloorLevelIndex || indexPath.row == RoomIndex)
{
[cell setUserInteractionEnabled: YES];
}
}
break;
default:
break;
}
【问题讨论】:
-
您不需要在案例开头设置大括号。
-
哪一行出现错误?
-
@cjrieck if (indexPath.row == FloorLevelIndex || indexPath.row == RoomIndex) 这个
-
@AnastasiaY 和
FloorLevelIndex和RoomIndex是什么?只是NSInteger或类似的东西?如果这些是类型,您将无法将数字与类型进行比较。你可能想要这些的数字表示。 -
@cjrieck 他们刚刚被定义,它没有工作。您应该将此添加为答案
标签: ios objective-c if-statement switch-statement