0

I'm new to Swift programming. When I look at my Udemy course, the functions are always completed automatically.

Example:

"switch" becomes

switch <#value#> {
case <#pattern#>:
<#code#>
default:
<#code#>
}

the word automatically becomes a whole code snippet with a placeholder. When I enter "switch", there is only the dropdown menu where I can select "switch" but the code is not automatically output. It just shows the word "switch".

Does anyone know how to activate the whole thing? My teacher on Udemy couldn't help me either.

I'm using the latest Xcode from the App Store (13.0) on a Macbook M1 2021 with macOs Big Sur 11.6.

tmk301
  • 1
  • 1
  • 1
    I know this is probably not the answer you're looking for. But Xcode just sucks and code completion just breaks. You have to do the rain dance to make it work again. This often happens when you have other compile errors in your code. Especially if you have circular references. Cleaning the project and closing Xcode could resolve the issue. Keep an eye out on the indexing process and if syntax highlighting is working. If function calls all look white, something is wrong. – Jacob Oct 11 '21 at 03:33

1 Answers1

0

Depending on your case.

If you type func viewD, you will get the full template. Otherwise Xcode interprets that you want to call the func, not to override it.

OR

Use Editor > Refactor > Add Missing Switch Cases

Convenient way:

  1. Open Preferences ( [command] + [,] ) in Xcode.
  2. Go to Key Bindings tab and set a shortcut for the command Refactor > Add Missing Switch Cases.
  3. Input the shortcut in editor. Be sure the cursor is on switch letters.
maximus383
  • 584
  • 8
  • 25