可可脚本:返回"零"与"缺少值" [英] Cocoa Scripting: Returning "null" vs. "missing value"

查看:448
本文介绍了可可脚本:返回"零"与"缺少值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,AppleScript的知道特殊值

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?

如果我回到 NULL )或 NSNull 从我的可可基于脚本的应用程序可脚本属性的getter,脚本编辑器间$ p $点,作为 缺失值

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.

如果我回到 [NSAppleEventDescriptor nullDescriptor] ,AppleScript的,甚至显示了一个错误。

And if I return [NSAppleEventDescriptor nullDescriptor], AppleScript even shows an error.

推荐答案

AppleScript的使用 typeNull 描述符,表示未分配的/没有价值,而失踪值重新由 cMissingValue typeType 描述psented $ p $。 (这是类似于JavaScript中的未定义 VS 乱七八糟的,类似的PITA)。

AppleScript uses a typeNull descriptor to indicate unassigned/no value, whereas missing value is represented by a typeType descriptor of cMissingValue. (It's analogous to the undefined vs null mess in JavaScript, and a similar PITA.)

这篇关于可可脚本:返回"零"与"缺少值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆