Search code examples
xcodeapplescriptapplescript-objc

Support With Sharing AppleScriptObjC Variable To Label Object


   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

So, this is an example of an app I'm working on in AppleScriptObjC. I've taken a lot out and replaced things with different strings, but this is the basic layout.

How can I get the value of 'testVariable' into the 'displayLabel' property, which is linked to a label in the interface builder? The label is empty initially, but I want the value of 'testVariable' to populate it once the script has been run.

Thanks!!!


Solution

  • The syntax is pretty similar to the ObjC syntax

    ObjC

    displayLabel.stringValue = testVariable;
    

    AppleScriptObjC

    set displayLabel's stringValue to testVariable