我看到了这个问题的一些答案,我明白了 - 你不能在一个内部声明和分配变量switch.但我想知道以下是否正确抛出错误说
错误:'int'之前的预期表达式
码:
switch (i) {
case 0:
int j = 1;
break;
}
Run Code Online (Sandbox Code Playgroud)
为什么NSLog()在它之前拨打电话会导致没有错误?
switch (i) {
case 0:
NSLog(@"wtf");
int j = 1;
break;
}
Run Code Online (Sandbox Code Playgroud) 我想我会失明,因为我无法弄清楚此代码中语法错误的位置:
if( cell == nil ) {
titledCell = [ [ [ TitledCell alloc ] initWithFrame:CGRectZero
reuseIdentifier:CellIdentifier ] autorelease
];
switch( cellNumber ) {
case 1:
NSString *viewDataKey = @"Name";
etc...
Run Code Online (Sandbox Code Playgroud)
当我尝试编译它时,我在最后一行的'*'标记之前收到错误:语法错误.
对不起这个基本问题,但我错过了什么?