1

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)
1

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
3
  • Hm. When do you use setStringValue and when do you use setString. Do you use value when it is a direct value, and do you use setString when the value is returned of something? – DisplayName Nov 28 '15 at 11:48
  • setString is a method for these classes ( NSTextView, NSMutableString and SFAuthorizationView), not for the NSTextField class. – jackjr300 Nov 28 '15 at 14:03
  • You can use a direct value or a returned value. – jackjr300 Nov 28 '15 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .