3

I'm brand new to the world of Xcode 4.4 and AppleScriptObjC. I'm trying to expand and experiment with a tutorial on AppleScriptObjC in the book "Learn AppleScript" by Sanderson and Rosenthal, and I've run into a problem. The code:

property parent : class "NSObject"
property textField : missing value

on buttonClick_(sender)
    set theText to textField's stringValue()
    set dialogText to text returned of (display dialog "Here is the text your entered: " & return & theText default answer "")
    textfield's setStringValue_(dialogText)
end buttonClick

runs perfectly, and I get the dialog as expected, and everything works. But if I try to mess around with it and add these two lines (in the appropriate places, of course):

property anotherTextField : missing value
...
set theText to textField's stringValue() & otherTextField's stringValue()

The program still runs - BUT! - if I go to the MainMenu.xib and ctrl-click AppDelegate to get the outlets inspector ... there is no Outlet for anotherTextField, even though there should be.

Any ideas?

2 Answers2

0

I'm new to AppleScript as well and a common problem I had was that I declared properties inside the applicationWillFinishLaunching section at first. Check that. If it still doesn't work (you did mention that you added the code in the appropriate place) then try placing the second text field's property declaration before the "property parent" part. Might work I suppose…

Try posting the full code of your AppDelegate.applescript

Good Luck!

0
  1. Make sure that the property you added isn't inside an action

eg. This won't work:

    on buttonClick_(sender)
        property anotherTextField : missing value
        ....
    end buttonClick

eg. This should work:

    property anotherTextField : missing value
    on buttonClick_(sender)
        ....
    end buttonClick
  1. PS. you made the variable "anotherTextField" but in the action you used "otherTextField"

    property ---> anotherTextField <--- : missing value
    ...
    set theText to textField's stringValue() & ---> otherTextField <---'s stringValue()
    
  2. If none of this helps, I might be able to understand it better if you post your complete code, then i might be able to help you more :D

YeaTheMans
  • 1,005
  • 8
  • 19