Returned BOOL values from Objc to Python

Patrick Robertson <[email protected]> Sat, 19 Oct 2013 20:36:35 +0900
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
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
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk