Possible Duplicate:
Declaring variables inside a switch statement
I'm having difficulty getting XCode to let me write a particular switch statement in Objective-C. I'm famiiar with the syntax and could rewrite it as if/else blocks but I'm curious.
switch (textField.tag) {
        case kComment:
            ingredient.comment = textField.text;
            break;
        case kQuantity:
            NSLog(@""); // removing this line causes a compiler error           
            NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init];
            fmt.generatesDecimalNumbers = true;
            NSNumber *quantity = [fmt numberFromString:textField.text];
            [fmt release]; 
            ingredient.quantity = quantity;
            break;
    }
I can't see the syntax error, it's as though I need to trick the compiler into allowing this.
 
     
     
     
    