I have this switch statement in my code:
switch(buttonIndex){
case 0:
[actionSheet dismissWithClickedButtonIndex:buttonIndex animated:YES];
Well this isn't a proper answer, as I don't know why you see that error, but a better solution than to move the declaration outside the switch block is to make explicit scopes within the individual cases of the switch block. That usually solves any such problem with switch statements, which are a bit weird in that the case statements share scope.
So:
switch (foo) {
case 0: {
// notice explicit scope here
break;
}
default: {
// here as well
}
}