Re: Executing AppleScript from Cocoa (with return values)
Re: Executing AppleScript from Cocoa (with return values)
- Subject: Re: Executing AppleScript from Cocoa (with return values)
- From: cricket <email@hidden>
- Date: Mon, 18 Aug 2003 13:49:19 -0700
I use this class method to turn an NSAppleEventDescriptor into an array
of strings. Note that descriptorAtIndex: is 1-based, not 0-based.
+ (NSArray *)arrayFromDescriptor:(NSAppleEventDescriptor *)descriptor {
NSMutableArray *returnArray = [NSMutableArray array];
int counter, count = [descriptor numberOfItems];
for (counter = 1; counter <= count; counter++) {
NSAppleEventDescriptor *desc = [descriptor
descriptorAtIndex:counter];
if (nil != [desc descriptorAtIndex:1]) {
[returnArray addObject:[self arrayFromDescriptor:desc]];
} else {
NSString *stringValue = [[descriptor
descriptorAtIndex:counter] stringValue];
if (nil != stringValue) {
[returnArray addObject:stringValue];
} else {
[returnArray addObject:@""];
}
}
}
return (NSArray *)returnArray;
}
- cricket
On Monday, August 18, 2003, at 1:32 PM, email@hidden wrote:
I'm looking at using this method myself, but I can't figure out from
the
documentation how I would access, in Cocoa, a list of strings returned
by the
AppleScript. I know it has to come out of the NSAppleEventDescriptor
object
but that's about all I know. It would be great to just be able to
make an
NSArray of NSString objects out of it. Can it be done in Cocoa or do
I need
to use the Carbon APIs with the aedesc data?
Take a look at NSAppleScript. (BTW, if you don't have it, get
AppKiDo
from http://homepage.mac.com/aglee/downloads/ ).
Wow -- I totally misses executeAndReturnError:, thinking that
executeAppleEvent:error: was the only way to go. Thanks for making me
look again!
----->
Software Entomologist Mail for Mac OS X
http://www.apple.com/macosx/panther/mail.html
---------->
Furniture tastes crispy!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.