MacOS – How to set a textfields string to a variable in AppleScript

applescriptmacosxcode

I want to set the text in a text field to a variable, in this case called variable1. Here's the part of my script.

on button836_(sender)
    set variable1 to quoted form of POSIX path of (choose folder with prompt "Choose")

That's the first part. But I also wanted to set the text in textField to the value of variable1.

I tried doing this:

    textField's setString:variable1

But it didn't work. Usually, I have a script that returns the value, and doing textField86's setString:script837 etc. usually works, but it's different here. I even tried this stupid solution:

    set variable1script to do shell script "echo " & variable1
    textField's setString:variable1script
    end button836_

Which should work but it just tells me:

2015-11-26 15:12:27.077 [etc.] AppDelegate button836:]: -[NSTextField setString:]: unrecognized selector sent to instance 0x6100001e0200 (error -10000)

Best Answer

You must use a method from the NSControl class --> Getting and Setting the Control’s Value

textField's setStringValue:variable1 -- variable1 must contains a string