【发布时间】:2015-09-16 03:33:18
【问题描述】:
我想用下面的表达式
-(void)SwitchCondn{
int expression;
int match1=0;
int match2=1;
switch (expression)
{
case match1:
//statements
break;
case match2:
//statements
break;
default:
// statements
break;
}
但我得到了
我在研究时发现
In order to work in Objective-C, you should define your constant either like this:
#define TXT_NAME 1
Or even better, like this:
enum {TXT_NAME = 1};
我很长时间以来一直在使用这种方法。现在我的变量值会在运行时发生变化,所以我需要以其他方式定义,我不想使用 if else 所以有没有其他方式声明变量的方式
我有研究过
Objective C switch statements and named integer constants
【问题讨论】:
标签: ios objective-c switch-statement