I’m working my way through Shane Stanley’s book about AppleScript Objective-C (excellent, btw). Now I’m on Chapter 8 which talks about how to make a drag and drop application using a handler that starts with:
on application_openFiles_(theApp, fileList)
log "app open: " & fileList
...
end
The chapter goes on to use another handler…
on applicationDidFinishLaunching_(aNotification)
log "did finish launching: " & fileList
if fileList = missing value then
-- do something
end if
end applicationDidFinishLaunching_
that is supposed to work like an AppleScript on run handler. However, the condition for the if statement (fileList = missing value) is only supposed to run if you double click the application vs. drop files on it.
I’ve taken the supplied project files and built a release version and I added a line to log the variable fileList. When I drop a file on the application, the value for fileList is a POSIX path in the application_openFiles_ handler, but when the applicationDidFinishLaunching_ handler runs, I log the same variable’s value as missing value, and so the conditional is met and the – do something runs regardless of whether you drop files on the application, or double click it.
The console log result when double clicking the application is:
3/14/13 10:12:37.726 PM Replacing Open: did finish launching: missing value
But, the console log result when dropping a file on the application is:
3/14/13 10:13:55.425 PM Replacing Open: app open: /Users/aj/Desktop/704.pdf
3/14/13 10:13:56.984 PM Replacing Open: did finish launching: missing value