0
property parent : class "NSObject"

    -- IBOutlets
    property theWindow : missing value
    set value1 to :value number 1

on buttonClick_(sender)
         set the clipboard to value1
    end buttonClick_

I'm very lost with the way Xcode is handling variable. My variable are reported not defined, I figured out that this is actually not the case when I set the variable in a "sender"

but what If I want to use a variable outside a button/sender ? or what if I want to use the same variable in two different buttons.

I have the feeling that what I'm asking not making much sense but hopefully someone will get me there.

1 Answer 1

1

It's like in Objective-C or Swift:

Either declare a property with a default value:

property value1 : 1

Or declare the property without a value and set the value in a handler:

property value1 : missing value

...

on applicationDidFinishLaunching_(aNotification)
   set value1 to 1
end applicationWillFinishLaunching_

AppleScript code must always run in a handler. Even in a simple compiled script if you write code on the top level of the script the compiler wraps the code in the implicit on run handler.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.