tags:

views:

68

answers:

1

Strange:

switch(type) {
    case NSFetchedResultsChangeInsert:
        int x = 5; // error: "Expected expression before int"

        break;
}

So it isn't possible to create a local variable in an switch-case-block?

+8  A: 

Did you try adding curly braces?

switch(type) {
    case NSFetchedResultsChangeInsert:
        {
            int x = 5; // error: "Expected expression before int"

            break; 
        }
}
dcp
You need to declare a new scope for some reason. My C isn't good enough to know.
Tom H
It is an oddity from the C standard. There is some weird syntactical edge case [that I'm perpetually running into] that prevents the compiler from "just working".
bbum