How to do a droplet in ASOC?

How would a droplet be coded in ASOC? The on open handler doesn’t seem to function.

Thanks in advance.

There are two parts to it. The code is simple: you use application_openFiles_ or application_openFile_ in the app delegate, as in:

on application_openFiles_(sender, fileList)
	repeat with i from 1 to count of fileList
		display dialog (item i of fileList) as text
	end repeat
end application_openFiles_

Note that you get a list of POSIX paths, and that it is called after applicationWillFinishLaunching_ (but before applicationDidFinishLaunching_).

But before it will work, you have to modify the bundle’s Info.plist file to tell it what files it should accept. The easiest way to do this is to choose Project → Edit Active Target… (or click the disclosure widget next to Targets in Xcode’s sidebar, click on the the app name that’s disclosed, and then click on the blue info button in the toolbar). In the window that opens, click on the Properties tab. Down the bottom, you add document types.

The only columns you need to worry about are the Role (best to choose Viewer), and one of OS type (four-letter codes, on the way out), Extensions, or UTI. You’ll need an entry for each UTI/extension/type you want the app to accept.

Thank you!

By the way, is the use of application_openFile(s)_ for droplets in ASOC documented somewhere? I was looking for appropriate docs, but couldn’t find this topic. But maybe I just didn’t know where to look.

Remember that the conversion from Objective-C to AppleScriptObjC is to replace the “:” in the method names with an underscore. To locate the corresponding Objective-C method in the docs you do the opposite coming from AppleScriptObjC.


-- becomes


Put this in the docs search field.



Thanks. I know about the colon-to-underscore convention and how to use Google and other resources to search for the names of methods.

I see now that I didn’t word my question clearly. What I meant to ask is this: where is it documented that the way to get the same (or similar) functionality to on open within ASOC is to use “application_openFiles_” (i.e., “application:openFiles:”) in the first place?

I searched for things like AppleScriptObjectiveC “on open” and AppleScriptObjectiveC droplet and didn’t come up with anything useful. I dare say that thousands of developers who’ve been working in (Apple)Script Editor and AppleScript Studio would be in the same boat: they wouldn’t know what to search for in order to get useful information about how to replace their on open handlers with something which works in ASOC.

… unless I have overlooked some docs which explain this. That’s why I asked this question: to try find these docs if they exist.

Currently there is no documentation for AppleScriptObjC. When I refer to docs, I am referring to the Xcode documentation found under the Help menu. There is also very little to be found on the internet using Google. This forum, my articles and samples from Matt Neuburg are the only resources I know of.

When I want to find out how to accomplish something in AppleScriptObjC, I look through the Cocoa docs or search Google. I search for an Objective-C solution and then convert that to AppleScriptObjC.

When something does not work the way I expect it to, I write the code out in Objective-C and test it there. Once I get it working correctly, I convert it.



It sounds like you figure these things out the same way I do. I just incorrectly thought that there were more AppleScriptObjC docs out there than there actually are.


Is there a way to quickly let the Application manage both folders and any file’s extension (like the ‘****’ in AppleScript Studio)?

If not how can I let the application manage only folders? (extension type?)


Through Project–>Edit Active Target “YOURPROJECTNAME”, then in Properties, adding a document types: entry, setting up:
“” in the UTI field works just fine.

I’m using the 10.7 SDK under Lion and I can’t find anything like Project->Edit Active Target in that version of Xcode.

Where do I go within Xcode version 4.1 for 10.7 to set up these document types?

Thanks in advance.

PS to the Sysadmins: Please add 10.7.x entries to the Operating System dropdown of this message-posting screen. Thanks.

Click the master drop-down item (your application) in the table on the far left. Then, making sure that the target is selected (which it is by default), click the info tab, and it is in there.

Aha! Got it.

Thank you very much.