Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
ObjC delegate method not called
-
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.
-
@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 -
@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...
-
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.