Re: Getting the results out of Applescript
Re: Getting the results out of Applescript
- Subject: Re: Getting the results out of Applescript
- From: Nathan Day <email@hidden>
- Date: Wed, 11 Jan 2006 00:11:30 +1100
desc is a NSAppleEventDescriptor, look at my NDAppleScriptObject
project on my web site it includes a category of
NSAppleEventDescriptor that handles conversion to and from Cocoa
classes. You can use that with NSAppleScript.
On 08/01/2006, at 12:12 AM, Mike Abdullah wrote:
I am having difficulties trying to get an AppleScript to work with
my app. Basically I have placed the script inside the resources
folder of my app, and I have written code that will run the script
no problem. However, I cannot figure out how to get the results of
my script. The script (ideally) does something like this:
return {value1:"foo1", value2: "foo2"}
This should (if I have understood things properly, correspond to an
NSDictionary). So how do you actually access these results? I
currently have the following code:
NSURL *scriptURL = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource: @"theScript" ofType:
@"scpt"]];
NSDictionary *theDict = [[NSDictionary alloc] init];
NSAppleEventDescriptor *desc;
NSAppleScript *theScript = [[NSAppleScript alloc]
initWithContentsOfURL: scriptURL error: &theDict];
desc = [theScript executeAndReturnError: &theDict];
[theScript release];
[theDict release];
So, if I understand it, the values returned by the script are now
stored in desc. However, how do I get them out? I see there is a
method for getting string values, data, and one that looks like it
probably does records and lists, button I cannot persuade it to work.
I also tried having the script simply do:
return "foo"
and then did [desc stringValue] but all I got printed to the log
was a sequence of numbers, which, bizzarley change each time the
script is run - surely it should be the same result each time!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden