2

UIButtons and other descendants of UIControl have the methods allTargets and actionsForTarget.

The method allTargets lets you find out which objects are targets for this control.

Then, actionsForTarget gives you an array of the actions that will be sent to that target.

I don't see any such thing in the UIGestureRecognizer class, and UIGestureRecognizers are not descendants of UIControl.

Is there a way to find out what target/actions are registered with the gesture recognizer?

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • Possible duplicate of: http://stackoverflow.com/q/20066315/2274694 And here's a related accepted answer: http://stackoverflow.com/a/20242145/2274694 – Lyndsey Scott Mar 15 '15 at 21:17
  • @LyndseyScott, thanks for those links. The suggested solutions rely on private instance variables of the gesture recognizer. At best that's fragile, and at worst may get you rejected by Apple's review process, so I guess the answer is that no, there is no supported way to do this. – Duncan C Mar 15 '15 at 21:59
  • If there is no public access to gesture recognizer's targets and selectors, why not store them manually in like a weakObjectsHashTable – dopcn Mar 16 '15 at 02:13
  • @dopcn, I was hoping to provide a simple solution to identifying a gesture recognizer that another poster is adding to a table view cell. I suspect that the system adds it's own gesture recognizers for things like swipe to delete, and wanted an easy way to tell if the gesture recognizer was the user-added one. If there was a way to look at the target/action(s) on the gesture recognizer then you could tell if it was the one you added. Sure, I could suggest that the user save a unique tag, perhaps using associative storage, but that's getting not-so-simple. – Duncan C Mar 16 '15 at 03:05

0 Answers0