Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Xcode func shows gray instead of white params

Hello i am working with Xcode and i have noticed that some function are behaving different then usual, for example :

function showing parameters in gray

  let config = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [UIMenuElement] in
        let downloadAction = UIAction(title: "Download",subtitle: nil, state: .off) { _ in
            print("download")
        }

why does Xcode show the functions in gray and not regular white?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

why when i select the function, Xcode writes the function without the parameters and I have to write them out manually?

>Solution :

That is because the parameters of those overloads are all optional. Optional parameters are all shown in grey in the autocomplete box in Xcode 14.

If the function has some required parameters, and some optional parameters, you can see that the required ones are in white, and the optional ones are in grey.

For example:

func foo(parameter1: Int = 0, parameter2: Int) {}

enter image description here

To insert all the parameters all at once, you can press option + enter, rather than just enter on its own, after selecting the overload using the arrow keys.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading