AppleScript Record and NSDictionary
AppleScript Record and NSDictionary
- Subject: AppleScript Record and NSDictionary
- From: Steve Cronin <email@hidden>
- Date: Tue, 21 Jul 2009 17:51:37 -0500
Folks;
From my Cooca app I want to call an AppleScript with several
parameters one of which is an AppleScript record.
I've got everything about calling and return values working smoothly.
What I can't seem to get is how to create that parameter record.
I have been able to build AppleScript lists using:
NSAppleEventDescriptor *stringDesc, *thisList =
[NSAppleEventDescriptor listDescriptor];
NSIndexSet *rowIndexes = [myTableView selectedIndexes];
unsigned int descIndex = 0, index;
index = [rowIndexes firstIndex];
do {
descIndex ++;
stringDesc = [NSAppleEventDescriptor descriptorWithString:[[myArray
objectAtIndex:index] valueForKey:@"someKey"]];
[thisList insertDescriptor:stringDesc atIndex:descIndex];
} while ((index = [rowIndexes indexGreaterThanIndex:index]) !=
NSNotFound);
When I look at the docs for -recordDescriptor and I see the 4
character code business - I get the ugly sinking feeling but maybe
that's the only way...
I've tried to move the coercion into AppleScript but there is nothing
that will do that except the magic 'user record fields'.
But there are warnings about resouce use for the 'magic' values....
(And anyway while seated in front of this machine, I don;t really like
magic!!)
- (NSAppleEventDescriptor) coerceDictionary(NSDictioanary *)dictionary {
NSAppleEventDescriptor *result = [NSAppleEventDescriptor
recordDescriptor];
NSArray *keysArray = [dictionary allKeys];
NSArray *valuesArray = [dictionary allValues];
unsigned int keyCoount = [keysArray count];
for ( i = 0; i < keyCount; i++) {
//the good stuff happens here....
}
return result;
}
So is there an exprienced soul out there who might share a snippet of
code or a an illuminating link?
Steve
_______________________________________________
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