How to autocomplete enum switch using Xcode?

Short Answer :

Use Editor > Refactor > Add Missing Switch Cases

Xcode screenshot

Convenient way :

  1. Open Preferences by pressing [command] + [,] in Xcode.
  2. Go to Key Bindings tab and set a shortcut for the command Refactor > Add Missing Switch Cases. xcode preferences screenshot
  3. Input the shortcut in editor. Be sure the cursor is on switch letters. xcode gif

Saw your question and decided to build an Xcode plugin that does exactly that.

Check it out: https://github.com/stefanceriu/SCXcodeSwitchExpander

SCXcodeSwitchExpander


in Xcode 10 do the following

  1. add switch...case template and set your enum type instead of self so that xcode understands what it should autocomplete

  1. move cursor inside word switch and go to menu > editor > refactor > expand switch cases

This is what you will get as result

Tags:

Ios

Enums

Xcode