Home > OS >  Xcode: Code completion for method parameters
Xcode: Code completion for method parameters

Time:07-13

Currently I learning Swift/SwiftUI and using Xcode. I have some "troubles" with autocompletion


Actual behaviour (example)

VStack can have 3 parameters alignment:spacing:content:

When I start type "spa" autocompletion shows and when I press Enter/TAB it automatically add all 3 parameters - which is correct


What I want:

It is possible to somehow add only one ? (In this case spacing). I know I can delete unnecessary parameters or type full length "spacing:" but is there any shortcut for this ?

Thanks for advice

CodePudding user response:

In the new Xcode 14, you can actually do this by:

  • if you want to call a VStack with only spacing as a parameter just type "vspa", then a VStack with (spacing:...) will come up. the "spacing" will be in bold format, then you just press enter to fill out everything.
  • Or "valign" for VStack with only alignment as a parameter.

For more info and how to do it, you can watch the latest video of Paul Hudson with the below link: https://www.youtube.com/watch?v=V2TDGeevDWo

  • Related