Make Cocoa application respond to simple AppleScript command?

Thanks for making the effort of adding applescript support to your app! Just a quick observation / criticism: When constructing terminology, by all means include spaces, but if that terminology takes the form of 'verb noun' (like 'do update') appleScripters will be irritated if the noun 'update' is not a properly modelled object, and if 'do' is not a proper command.

Up vote 4 down vote favorite share g+ share fb share tw.

I am trying to add a trivial AppleScript support to a Cocoa application. The application performs a check periodically and I just want to be able to tell it to perform it on demand. I am trying to follow the SimpleScriptingVerbs Apple example.

I have subclassed NSScriptCommand as follows: Header: #import @interface rdrNotifierUpdateCommand : NSScriptCommand { } -(id)performDefaultImplementation; @end Implementation: #import "rdrNotifierUpdateCommand. H" #import "rdrNotifierAppDelegate. H" @implementation rdrNotifierUpdateCommand -(id)performDefaultImplementation { NSLog(@"Works at last"); ((rdrNotifierAppDelegate *)NSApplication sharedApplication delegate) checkForNewItems; // This just fires the timer return nil; } @end My .

Sdef file goes as follows (and the problem seems to be there, but I cannot find it): The Info. Plist is set up appropriately. But, when I try to run the following script in AppleScript editor: tell application "rdrNotifier" do update end tell I receive an error about variable "update" not being defined.

I can open the dictionary for my application from AppleScript Editor (i.e. It is successfully registered). Edit: Found a solution The problem was indeed in the sdef file: I was not specifying that the application can reply to the command.

My final definition goes as follows (Obj-C code unchanged): Any improvements/tips/criticisms are still welcome. Cocoa applescript link|improve this question edited May 15 '11 at 8:49 asked May 14 '11 at 19:29Raúl Pedroche384.

Thanks for making the effort of adding applescript support to your app! Just a quick observation / criticism: When constructing terminology, by all means include spaces, but if that terminology takes the form of 'verb noun' (like 'do update') appleScripters will be irritated if the noun 'update' is not a properly modelled object, and if 'do' is not a proper command. I would argue that 'do' is a poor choice for a command name, because it is very vague.

What's wrong with just using 'update' as the command? (i.e. Treat it as a verb).

This issue is treated in some detail by Apple's own technote 2106 (currently here), which you definitely should read and digest if you hope to please your AppleScripting user community. Apple themselves are not beyond stupid terminology choices such as updatePodcast and updateAllPodcasts (in iTunes). These are stupid choices because (according to tn2106) they contain no spaces, and because the better choice would be to have a proper podcast class and then have an update command which could be used on an individual podcast, all podcasts, or a particular chosen set of podcasts.

Thank you very much for pointing me to the technote. Yes, "do update" sounds silly; putting "do" (I meant "perform", but using that would not help too much either) does not make any sense. I have changed the code to a single verb and, in fact, tossed out also "update" and ended up with "refresh".

– Raúl Pedroche Jun 6 '11 at 14:27 refresh sounds great! :) very refreshing – brennanyoung Jun 6 '11 at 18:09.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions