[英]Weird “Switch Case” statement
我的文件之一中包含以下代码:
switch ([sender tag]){
...
case 100:
UIView *v1 = [UIView alloc] initWithFrame blabllabla...
[v1 bla bla bla...
break;
...
看起来很标准吧? 但这给了我这个错误:
"Use of undeclared v1"
然后我输入“ NSLog()”或“ if”语句,如下所示:
case 100:
NSLog(@"why need a nslog here?");
要么
case 100:
if(1==1) {
...
然后就可以了。
有人知道为什么吗? 是我的代码还是Objective-C规则?
case
不使用C块,则不能声明作用域仅限于case
变量。 更改为:
case 100:
{
UIView *v1 = [UIView alloc] initWithFrame blabllabla...
[v1 bla bla bla...
break;
}
它应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.