首页 > 解决方案 > 如何在 AppleScriptObj 中获取 NSImage.Name

问题描述

怎么获得NSImage.Name.cautionName

在 AppleScriptObj 中。我试过了:

set cautionName to aN of NSImage.Name

但这不起作用。

标签: macosapplescriptnsimageapplescript-objc

解决方案


看起来您所追求的是NSImageNameCaution,这是系统映像名称的常量。您的示例(和链接)似乎正在使用Swift,更改文档语言以Objective-C提供正确的术语。

AppleScriptObjC使用来自Objective-C文档的名称(它也不使用点表示法),所以它类似于:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "AppKit"
use scripting additions

# get the name
set imageName to (current application's NSImageNameCaution) as text
# get the image
set theImage to current application's NSImage's imageNamed:(current application's NSImageNameCaution)

推荐阅读