• 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
AppleScript Record and NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: AppleScript Record and NSDictionary
      • From: Jim Correia <email@hidden>
  • Prev by Date: change color on a NSButton
  • Next by Date: Re: Missing vertical scroll bar - resolved
  • Previous by thread: change color on a NSButton
  • Next by thread: Re: AppleScript Record and NSDictionary
  • Index(es):
    • Date
    • Thread