It appears that AppleScript knows the special value null.
How do I return such a value from my Cocoa Scripting based app for a scriptable property?
If I return nil (NULL) or NSNull for a scriptable property getter from my Cocoa Scripting-based app, the script editor interprets that as missing value.
And if I return [NSAppleEventDescriptor nullDescriptor], AppleScript even shows an error.
I'm using the
cMissingValueversion of "null", like so:I decided to use that based on the testing below.
I'm using Swift to run and passing parameters to an AppleScript subroutine, using the code here:
Passing variables to an AppleScript
These parameters are passed to the AppleScript subroutine, and I've commented each results:
The
NSAppleEventDescriptor.null()version seems to for some reason be getting the "current application" value.It seems like I may want to use the
cMissingValueas shown in the other answer.The variables can be nil-checked in AppleScript like so:
NSAppleEventDescriptor.null()does not hit this check. TypecMissingValuedoes.I've added it as a Swift Extension:
NSAppleEventDescriptor.missingValue()