Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

applescriptobjc object identifier

I have developed an app (some time ago) in Xcode using applescript. I'm adding new features so I need to rework the app using applescriptobjc. I'm new to this version of applescript, and how to properly use it with the objects (buttons/popups). The old Xcode you gave the object a name/identity, and used applescript to to control it. I assume the concept is similar? I can't seem to figure out how/were to give the object a name to be able to control it. I have a popup button, and want to load it with an array.


I have seen examples and understand the what its doing, but the examples never show (that I can see) how the name used in the script connects to a specific object.


set catList to {"next item", "another item", "Items added"}
myPopUp's addItemsWithTitles_(catList)


how would you tell a specific popup button to be "myPopUp"


Hopefully I wasn't confusing, just wanted to be clear.

Posted on Jul 29, 2015 4:35 PM

Reply
Question marked as Best reply

Posted on Jul 29, 2015 5:58 PM

AppleScriptObjC does not use the object name/specifier like AppleScript Studio did (well, the Cocoa bits, anyway), and works a little bit more like Objective-C. Typically what you do is create a property and give it the value "missing value". A property with this value is noticed by Xcode, and shows up in the Interface Builder so that you can connect your object to that outlet. Once connected, the outlet property then contains a reference to the instance of your object.

4 replies
Question marked as Best reply

Jul 29, 2015 5:58 PM in response to Jon Lopiano

AppleScriptObjC does not use the object name/specifier like AppleScript Studio did (well, the Cocoa bits, anyway), and works a little bit more like Objective-C. Typically what you do is create a property and give it the value "missing value". A property with this value is noticed by Xcode, and shows up in the Interface Builder so that you can connect your object to that outlet. Once connected, the outlet property then contains a reference to the instance of your object.

Jul 30, 2015 7:41 AM in response to red_menace

Red_menace

Thanks for the response, with this and some visual aids/tutorials I found what I needed. Binding inspector:Model key value. I got my two popups to work with missing values, but I can't get them to populate (just using the syntax from examples and changing names.)

This is what I got.


script AppDelegate


propertyparent : class"NSObject"



-- IBOutlets

property theWindow : missing value

property publication : missing value

property pubdate : missing value


on applicationWillFinishLaunching_(aNotification)

set catList to {"next item", "another item", "Items added"}

publication's addItemsWithTitles_(catList)

end applicationWillFinishLaunching_


on applicationShouldTerminate_(sender)


-- Insert code here to do any housekeeping before your application quits

return current application's NSTerminateNow

end applicationShouldTerminate_


endscript


This is an error I get

2015-07-30 10:27:28.230 Classified Builder 5[1114:88762] *** -[AppDelegate applicationWillFinishLaunching:]: missing value doesn’t understand the “addItemsWithTitles_” message. (error -1708)

both popups are connected to willfinishlaunching, is it some typo I'm not seeing, or I'm just doing it wrong.

(trying to climb a steep learning curve, but I want to learn this)

Jul 30, 2015 1:08 PM in response to Jon Lopiano

ignore that last post I saw a video that appeared to do it the old way, but this it wasn't what I thought it was. Through Digging through the web I see you need to bind/connect the objects. I a bit to figure you need to bind the object two ways from the script to the object to give the object identity, and then from the object to the script to get it to perform the function/action (For those who search for a similar problem).

I just want to figure out if you can have multiple scripts, or all the code needs to sit in the apple delegate script. Multiple are easier to change update if needed (my opinion)...Thanks

Jul 30, 2015 7:02 PM in response to Jon Lopiano

Yes, you can have multiple script objects. There are a few ways to create them, but the easiest would probably be to add a new script file to your project, then in the Interface Builder add a NSObject (blue cube) and change its class (using the Identity Inspector) to the name of your new file. From there you can create properties in your other script(s) and connect them to the new script like any other object.


You might want to check out macosxautomation.com for more resources and information.

applescriptobjc object identifier

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.