Skip navigation.
 
mlRe: Sending non-string parameters to an AppleScript
FROM : Mike Abdullah
DATE : Sun Jul 23 19:08:26 2006

Use somethign like this:

NSAppleEventDescriptor *xCoordinate = [NSAppleEventDescriptor 
descriptorWithInt32: myPoint.x];
NSAppleEventDescriptor *yCoordinate = [NSAppleEventDescriptor 
descriptorWithInt32: myPoint.y];

NSAppleEventDescriptor *newPoint = [NSAppleEventDescriptor 
listDescriptor];
[newPoint insertDescriptor: xCoordinate  atIndex: 1];
[newPoint insertDescriptor: xCoordinate  atIndex: 2];

Then pass newPoint off to your script.  Your script might have to do 
a little work to reassemble the point into something the Finder can 
understand.

In fact, you could probably wrap the above up into a Category for 
NSAppleEventDescriptor for something like descriptorWithPoint:

Mike.

On 23 Jul 2006, at 3:58PM, Jeremy Dronfield wrote:

> I'm calling an AppleScript using NSAppleScript and 
> NSAppleEventDescriptor. Part of the the purpose of the script is to 
> set the positions of the icons in a Finder window. My problem is in 
> working out how to pass a parameter (in this case a point) which 
> isn't an NSString, since +[NSAppleEventDescriptor 
> descriptorWithString:] seems to be the only way of passing an Obj-C 
> data type. In desperation I've tried using:
>
> [NSAppleEventDescriptor descriptorWithString:NSStringFromPoint
> (NSMakePoint(100, 100))]
>
> and coercing the parameter to a point in the script with:
>
> set position of item fileRef of windowRef to (newPosition as point)
>
> but it doesn't work. I get an error: "{100, 100}" cannot be 
> converted to type point. Surely it must be possible to pass a point 
> (and other data types) to an AppleScript? If so, how?
>
> Jeremy
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
> 40gmail.com
>
> This email sent to mike.<email_removed>

Related mailsAuthorDate
mlSending non-string parameters to an AppleScript Jeremy Dronfield Jul 23, 16:58
mlRe: Sending non-string parameters to an AppleScript [SOLVED] Jeremy Dronfield Jul 23, 18:34
mlRe: Sending non-string parameters to an AppleScript Mike Abdullah Jul 23, 19:08
mlRe: Sending non-string parameters to an AppleScript Jeremy Dronfield Jul 24, 10:23