Hey everyone,
Been lurking the tutorials for a while and I’m working on building an app for data copying purposes. I have it all written out and it works well in just applescript, but for what I want to do, I want to use Xcode so that I can add help menus etc. But as I’m a beginner to cocoa I’m not sure how to make it so the text fields I have created (using Xcode tut 1) apply whatever is typed there to the variables i want to set in my applescript.
Typically the way I do it is create a few properties such as:
property textFieldOne : missing value
property textFieldTwo : missing value
property textStringOne : missing value
property textStringTwo : missing value
and then link the appropriate properties to the text fields in Interface Builder using the option for Referencing Outlet. I can then get the string value of the text fields, doing something like:
on getTextFieldStrings_(sender)
set textStringOne to textFieldOne's stringValue()
set textStringTwo to textFieldTwo's stringValue()
end getTextFieldStrings_
I would have a button that is clicked in the UI that calls the getTextFieldStrings method. The button would be linked to getTextFieldStrings Interface Builder using the option for Selector. There are a number of posts about this kind of thing here, so it should be easy to find. You can start with: