youssef mostafa youssef mostafa - 10 months ago 94
iOS Question

What is target in gesture recognizer?

UITapGestureRecognizer(target: , action: )
hi guys i'm new to IOS development, so could any body tells me the use of target here
thanks in advance.

Answer Source

Target - means the object, where UIGestureRecognizer will look to find the action.

From documentation: target - an object that is the recipient of action messages sent by the receiver when it recognizes a gesture. nil is not a valid value.

So, for example if you adding UIGestureRecongnizer for the view of view controller you have to add self as a target.