How to autocomplete enum switch using Xcode?
Short Answer :
Use Editor
> Refactor
> Add Missing Switch Cases
Convenient way :
- Open
Preferences
by pressing[command]
+[,]
in Xcode. - Go to
Key Bindings
tab and set a shortcut for the commandRefactor > Add Missing Switch Cases
. - Input the shortcut in editor. Be sure the cursor is on
switch
letters.
Saw your question and decided to build an Xcode plugin that does exactly that.
Check it out: https://github.com/stefanceriu/SCXcodeSwitchExpander
in Xcode 10 do the following
- add
switch...case
template and set your enum type instead ofself
so that xcode understands what it should autocomplete
- move cursor inside word
switch
and go tomenu > editor > refactor > expand switch cases
This is what you will get as result