calling the run method in an AppleScript from a cocoa application
calling the run method in an AppleScript from a cocoa application
- Subject: calling the run method in an AppleScript from a cocoa application
- From: David Alter <email@hidden>
- Date: Fri, 12 Mar 2010 08:56:58 -0800
I need the ability to call an AppleScript from a Cocoa Application. I have
done this in the past using NSAppleScript and it works great. This time I
need to call the "on run" and pass in parameters. That I have not done. I
looked at the following Tech note Technical Note TN2084: Using AppleScript
Scripts in Cocoa
Applications<http://developer.apple.com/mac/library/technotes/tn2006/tn2084.html#TNTAG5>
and
it talks about running a subroutine in apple script and passing in
parameters. The example I have been able to get working, but if I try and
call the run method it does not work. I suspect it is the event parameter
that is incorrect.
Here is code. It is basically the same code that was in the tech note but it
is calling "run" as appose to "sow_message". Run is a reserved word and
clearly acts differently.
NSAppleEventDescriptor* handler =
[NSAppleEventDescriptor descriptorWithString:
[@"run" lowercaseString]]; //here is where I'm trying to setup the
subroutine to call
NSAppleEventDescriptor* event =
[NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite
eventID:kASSubroutineEvent //I suspect that this eventID is not correct.
targetDescriptor:target
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
[event setParamDescriptor:handler forKeyword:keyASSubroutineName]; //I
suspect that this is not needed or is incorrect
[event setParamDescriptor:parameters forKeyword:keyDirectObject];
Does someone know how I should be setting up these events.
thanks for the help
-dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden