Suppose I have the following function:
@objc func action(_ gesture : UITapGestureRecognizer){}
Now to call the function, we usually use a syntax like so:
let mygesture = UITapGestureRecognizer(target: self, action: #selector(action(_:)))
What does the syntax action(_:)
actually mean? How are we passing the value of the input parameter gesture
required by the function? Doesn't it has to be something like action(_: somevalue)
From my guess, we are only providing the access to the function by writing action(_:)
. And the function is actually called by passing the mygesture
variable itself when the tap gesture is triggered. Is that correct?
You're right. You're passing the pointer of the function to the gesture recognizer.