• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting the results out of Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting the results out of Applescript


  • Subject: Getting the results out of Applescript
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 7 Jan 2006 13:12:49 +0000

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
  • Follow-Ups:
    • Re: Getting the results out of Applescript
      • From: Nathan Day <email@hidden>
    • Re: Getting the results out of Applescript
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Interface declaration
  • Next by Date: Re: Binding to to-one relationship
  • Previous by thread: Re: Interface declaration
  • Next by thread: Re: Getting the results out of Applescript
  • Index(es):
    • Date
    • Thread