If i try to create variable in case statement it gives me build erroe Can anyone clue me in why this syntax gets me a build error ("expected expression before 'NSMutableArray'").
+1
A:
Assuming you try do something like:
switch (...){
case someCase:
NSMutableArray *array = ...
break;
...
}
c (and so objective-c) does not allow to declare variables inside switch-case statement. If you want to do that you must limit the variable scope by putting your code inside {} block:
switch (...){
case someCase:{
NSMutableArray *array = ...
}
break;
...
}
Vladimir
2010-10-21 11:57:05
+2
A:
add brackets {} in your case statement to be able to declare variables
Benoît
2010-10-21 12:10:02
Thanks Benoit. Adding curly braces fixed the issue
Swapna
2010-10-21 12:17:27