Hi:
Still playing around with Applescript and xCode (I’ve slugged thru the first couple of chapters in Shane’s book which has helped) but I’m still missing something as far as output goes.
Here’s my code:
script AppDelegate
property parent : class "NSObject"
property fieldOne : missing value
property fieldTwo : missing value
property fieldThree : missing value
on setWindowFields_(sender)
set fieldOneValue to fieldOne's stringValue()
set fieldTwoValue to fieldTwo's stringValue()
-- set concatenatedString to current application's NSString's stringWithFormat_("%@%@", fieldOneValue, fieldTwoValue)
fieldThree's setStringValue_("20")
end setWindowFields_
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
My interface is just three text fields binded to their respective properties.
What I’m trying to do is enter text into the first two fields and then concatenate them into the third when I hit the push button.
When I couldn’t get that to work, I commented out the concatenate line and just tried to write a value back to the third box. When I hit the push button, I get:
2012-09-05 09:56:52.060 test3[86996:303] -[__NSCFString stringValue]: unrecognized selector sent to instance 0x102669e50
2012-09-05 09:56:52.070 test3[86996:303] *** -[AppDelegate setWindowFields:]: -[__NSCFString stringValue]: unrecognized selector sent to instance 0x102669e50 (error -10000)
When I control click on the AppDelegate cube the three referencing bindings are shown. Then all three properties are also listed as output so I thought I should connect fieldThree to the Field Three text box as an outlet but that produced all sorts of errors.
Could someone point me in the right direction on what I need to do in the interface to write back a value to a text field?
Thanks.
–jon