Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically populate Cases in a Switch statement based on the values in an enum

Tags:

xcode

ios

Is there a quick way to fill the cases in a switch statement in Xcode? I figure if an enum value has 6 possible cases, all 6 cases could easily be pre-populated based on the typedef.

like image 238
codeperson Avatar asked Dec 10 '11 17:12

codeperson


People also ask

Can we create switch statement using enum?

We can use also use Enum keyword with Switch statement. We can use Enum in Switch case statement in Java like int primitive.

Can enum be checked in switch case statement in C?

Can enum be checked in a switch-case statement? Yes. Enum can be checked.

Can Switch case have expression?

The expression in the switch can be a variable or an expression - but it must be an integer or a character. You can have any number of cases however there should not be any duplicates. Switch statements can also be nested within each other. The optional default case is executed when none of the cases above match.

How do switch statments work?

The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluates its expression, then executes all statements that follow the matching case label.


2 Answers

Sorry, but no. You can cut and paste, but that's about it.

like image 196
leanne Avatar answered Oct 07 '22 18:10

leanne


This is possible in Xcode by installing a plug-in called SCXcodeSwitchExpander:

https://github.com/stefanceriu/SCXcodeSwitchExpander

like image 26
codeperson Avatar answered Oct 07 '22 20:10

codeperson