script AppDelegate
property theWindow : missing value
property displayLabel : missing value
on applicationWillFinishLaunching:aNotification
display dialog "Are you ready?" buttons {"Yes", "No"} default button "Yes"
end applicationWillFinishLaunching:
if result = {button returned:"No"} then
display alert "That's a shame."
tell application "This Application"
quit
end tell
else if result = {button returned:"Yes"} then
set testVariable to "this is a test"
end if
end script
这是我在AppleScriptObjC中工作的一个应用的例子。我已经用不同的字符串替换了很多东西,但这是基本的布局。
我怎么能得到'testVariable'的值到'displayLabel'属性,这是链接到一个标签在界面构建器?标签最初是空的,但是我想在脚本运行后用'testVariable'的值填充它。
谢谢! !
语法与ObjC语法非常相似
ObjC
displayLabel.stringValue = testVariable;
AppleScriptObjC
set displayLabel's stringValue to testVariable