Xcode has a cool feature, closure parameters completion. You can predefine parameter names for the trailing closure syntax:
func myFunction(
_ operation: /*@START_HIGHLIGHT@*/(_ int: Int) -> Void/*@END_HIGHLIGHT@*/
) {
operation(1)
}
And then when you call the function:
myFunction(/*@START_MENU_TOKEN@*/operation: (Int) -> Void/*@END_MENU_TOKEN@*/)
You press Enter and Xcode automatically names the parameter:
myFunction { int in
}
For the parameters that the user needs to pick the name for, you can omit the label and Xcode will let the user pick the name:
func myFunction(
_ operation: /*@START_HIGHLIGHT@*/(_ int: Int, Int) -> Void/*@END_HIGHLIGHT@*/
) {
operation(1, 2)
}
myFunction(/*@START_MENU_TOKEN@*/operation: (Int, Int) -> Void/*@END_MENU_TOKEN@*/)
myFunction { int, /*@START_MENU_TOKEN@*/Int/*@END_MENU_TOKEN@*/ in
}