Determine which initialiser is used

I would like to know which initialiser is used when creating an instance.


Is there a way to do find this ?

Attempts made:

  • Normally I press Command + Control and Click to find out the declaration (for functions). However when I do the same on the type, it goes to Type declaration instead of the actual initialiser used.

Reason for asking:

  • I was finding it difficult when there are around 10 initialisers that use generics, it becomes a little difficult to go through the specification of each one to understand which one was used.
  • These are types defined in the frameworks like Combine.

If you write out the .init part explicitly, then you can command-click on that.


@Nevin Wow, Thank you so much !!! was breaking my head over it.

Just had to suffix .init to the type and worked like magic, didn't have to change anything else.

1 Like

It often works to cmd+click on one of the parameter labels in the initialiser.

1 Like

Thanks @sveinhal, I didn't know that. It seems to work for my own initialisers.

In some cases Command + click on the parameter name didn't work for example:

//SwiftUI code
Button(action: {}) {
    Text("Add Data")

It was listing properties as shown below, not sure if it is a bug or I am missing something.