Forum Archive

ObjC delegate method not called

mikael

Requesting ObjC guru assistance or just help from any otherwise sharp eyes.

I have this delegate method:

def gestureRecognizer_shouldReceive_(_self, _sel, gr, touch):
  print('check')
  return True

As part of this delegate class:

  PythonistaGestureDelegate = create_objc_class('PythonistaGestureDelegate',
  superclass=NSObject,
  methods=[
    gestureRecognizer_shouldReceive_,
    gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer_,
    gestureRecognizer_shouldRequireFailureOfGestureRecognizer_,
    gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer_],
  classmethods=[],
  protocols=['UIGestureRecognizerDelegate'],
  debug=True)

The other methods work, this one does not, and I do not know how to even debug this. Any ideas would be mush appreciated.

JonB

@mikael said:

UIGestureRecognizerDelegate

shiuldnt that be gestureRecognizer_shouldReceiveTouch_
or
gestureRecognizer_shouldReceivePress_?

I dont see a generic shouldReceive in the protocol:
https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate?language=objc

mikael

@JonB, that was it, thank you!

I was lead to this documentation by Google, which does not have separate touch and press methods. Looking at the page, I still find it hard to see that I am in the wrong place - I noticed that it did not look exactly like ObjC, but thought the API would be the same regardless...

JonB

yeah, that is Swift. I think the swift convention is that "nouns" become the equivalent of kwargs, whereas in objc everything was in the selector, but is redundant when you are reading code. When reading swift api's, a lot of times you can guess the ObjC equivalent by putting the parameter name into the selector.