[Pyobjc-dev] Returned BOOL values from Objc to Python
Brought to you by:
ronaldoussoren
From: Patrick R. <rob...@gm...> - 2013-10-19 11:42:36
|
Hi all, I'm currently creating a PyObjc app which uses a mixture of PyObjc and Plain Objc (mainly for view stuff). I have a method in one of my (Objective-C) view controllers as follows: @implementation MyVC - (BOOL)isVisible { return [self.mySpecialView isVisible] } in Python, I call this: # myviewcontroller = MyVC.alloc().init() # …stuff isVisible = myviewcontroller.isVisible() if isVisible is False: # do something special Now, I'd expect this call through to my Objective-C method to return a Python bool value of True or False. However, it seems to return an int (1 or 0) I've checked this with repr(isVisible) and what have you. This subsequently causes the line: if isVisible is False: to fail (since 0 is not False) Of course I can do if isVisible == False: to get round this, but I feel like if I'm declaring a BOOL in Obj-C I should get one pack in Python P.S. I've tried casting the return value of my Obj-C method to a BOOL just incase that'd make a difference. It doesn't. Thanks for any help |