Forum Archive

objc nil?

JonB

in the beta ctypes/objc_utils module, is there a way to send nil as a selector argument? i was trying to use locationOfTouch_inView_ with a nil view, but none of None, ns(None), ObjCInstance(0) worked.

omz

None should work. What happens when you pass that? I have a suspicion that this might be related to 32/64-bit again...

omz

I just tried this on a first-gen iPad mini (32-bit), and it worked fine, so 32/64-bit is probably not the issue here.

To test it, I've put this code in the [MapView Example]'s long_press method:

# ...

def long_press(self, sender):
    touch_loc = self.recognizer.locationOfTouch_inView_(0, None)
    print touch_loc.x, touch_loc.y
    # ...

Perhaps you're passing something invalid for the touch parameter? Note that not all gesture recognizers actually track multiple touches; the maximum value should be recognizer.numberOfTouches() - 1, where numberOfTouches() returns the number of touches that actually participate in the gesture (while there might be other touches on the screen).