AppleScript methods returns true but OBJ c reading it as false?

In Mac OS Ventura my AppleScript returns true but the obj C method calling it reads false…

Applescript delegate script

on checkIfDiskExists:pathString
–do something to check pathString if volume is present
return true
end checkIfDiskExists:

OBJC calls AppleScript method:

BOOL isVolume = [applescriptDelegate checkIfDiskExists:somepath];

if isVolume…

returns false!

yet if AppleScript returns 1 it works, but not with true?

Thanks, Rob

I think the difference in how to write the POSIX path between AppleScript and cocoa is suspicious.

AppleScript POSIX path:
/path/to/folder/

Cocoa POSIX path:
/path/to/folder

I did experience the same issue. I couldn’t find any consistency or explanation for this. Since then I just make sure to return a number or string instead of a boolean in AppleScript handlers called from Obj-C.

Check the class of isVolume – it sounds like it might be an NSNumber.

As far as I understand, isVolume in this case is the return value of hard coded return true

Forgot about this thread, just getting over Covid!

I changed return type on the declaration for the applescript handler in the OBJc file to id

-(id)checkIfDiskExists:(NSString*)destString fromSchedule:(NSNumber *)frmSch;

Now it return correctly when coerced to BOOL

BOOL isVolume = [applescriptDelegate checkIfDiskExists:somepath];

if I get the class on the id return it’s NSCFBoolean. Not sure how to get the class from the BOOL return- can’t call className on a BOOL…

I changed all my return values to 0 and 1 instead of true, false and it works now with the original BOOL declaration… or I can change the declaration to -(id)… and leave the true and false. Sticking with 0 and 1 as it seems less error prone?

Cheers, Rob