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: email@hidden
- Date: Mon, 18 Aug 2003 21:25:40 +0000
Ah, so this will keep the hierarchy of lists of lists [of lists [of lists
[...]]] of strings intact, correct? Pretty neat. I assume that you could
expand this to represent returned AppleScript records as NSMutableDictionary
objects within the hierarchy. For the application I have in mind, though, I
can manage with a list of lists.
I'm curious, though. Why do you resend [descriptor descriptorAtIndex:counter]
inside the else block when the result should already be in desc? Am I missing
something?
>
>
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;
>
}
_______________________________________________
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.