call method and passing booleans


This is a minor inconvenience but it seems that you cannot pass applescript true & false as part of the call method routine as objective c wants YES or NO which do not appear to be the same.

if you pass 1 for yes and 0 for no everything seems to work as expected, if you pass true for yes and no for false it does not work in my code.

Can anyone confirm this?



Hi Terry,

I can’t confirm. I have never had problems passing boolean AppleScript values.

call "mymethod:" of "myclass" with parameter {true}
(void)mymethod:(BOOL)boolvalue{ ...

-> boolvalue results YES as expected


call "mymethod:" of "myclass" with parameter {true}

(void)mymethod:(NSNumber *)boolNumber{ ...

-> [boolNumber boolValue] results YES - does also work.

Probably is your problem somewhere else …
Maybe you can post some code …?


Actually, I expect the above method to return void, because its return is declared void. Perhaps this would be more semantic:

- (BOOL)myMethod:(BOOL)boolValue { // blah blah, your method code here return YES; }

I thought Terry was talking about passing a BOOL from AppleScript to Objective-C - not vice versa???

Maybe you misunderstood what I wrote here:

What I meant was the resulting value inside of the Objective-C method - not it’s return value …

It’s easy to misunderstand unclear language.

“-> boolvalue results YES as expected”

“Results” may not be the best word here. :wink:

my fault … plz forgive me! As you probably have noticed English is not my native language - so it’s often difficult for me to express exactly what I mean :wink:

No worries.

It wasn’t a shot, just reasoning for why I posted what I posted. :slight_smile:


I have been experimenting and in my code:

call method “setIsLibraryOpen:” of class “LibraryData” with parameters {true} WORKS

call method “setIsLibraryOpen:” of class “LibraryData” with parameter {true} DOES NOT WORK

call method “setIsLibraryOpen:” of class “LibraryData” with parameter true DOES NOT WORK

I don’t know if this clarifies it or not.



And going the other way…

set tIsLibraryOpen to (call method “isLibraryOpen” of class “LibraryData”) as boolean WORKS

set tIsLibraryOpen to call method “isLibraryOpen” of class “LibraryData” as boolean DOES NOT WORK

set tIsLibraryOpen to call method “isLibraryOpen” of class “LibraryData” DOES NOT WORK