First, note that the gesture recognizer should only be attached to view one . You must create a new instance for each button.
To answer your question, you can add tag values ββto your buttons:
Button1.tag = 1000; Button2.tag = 1001;
Then check them in the recognizer:
UIView *view = sender.view; int tag = view.tag; if (tag == 1000) { ... }
You can enter any tag values, but I often start with a value as high as 1000 to avoid collisions with any other tags that I assign in Interface Builder.
Another option is to use a different processing function for each recognizer.
source share