What has the reference to the variable in the method

func someMethod() {
var variable = "someString"

'who' has the referentce to the variable?

The function. Who else could have it?

who has the reference to the function,how can I check for it?

By 'who has the reference', do you mean who own's the function or who is the caller of the function?

  • If it's in a type then the type owns it, if it's not in the type then the module owns it and it's a global function (can be limited to the current file)
  • In Xcode you can right click on the function and try 'Find Call Hierarchy'

Is function and its owner's relationship a reference?

Functions are reference types like classes are also reference types in Swift, if that's what you've asked about.


1 Like

is it right?