I have a gesture recognizer attached to a view and I’d like to be able to unit test which method it calls when the tap occurs. My gesture recognizer is created like so…
- (void)setupMyView {
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myViewTapped)];
self.myView.userInteractionEnabled = YES;
[self.myView addGestureRecognizer:tap];
}
How can I access the name of the selector (myViewTapped) that is called when the tap occurs?
Thanks so much in advance for your wisdom!
Unfortunately, neither
UIGestureRecognizernorUITapGestureRecognizerexposes this information.UIControl, for example, exposesallTargetsandallControlEvents, which is basically what you are looking for, but it is unfortunately unavailable forUIGestureRecognizerAs a result, I do not believe what you want is possible without using private methods.