• 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
re: NSAppleScript shies away from porcupines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: NSAppleScript shies away from porcupines


  • Subject: re: NSAppleScript shies away from porcupines
  • From: has <email@hidden>
  • Date: Tue, 26 Aug 2008 19:41:18 +0100

Jason Coco wrote:

I did a test with this... it seems that the code to resolve the alias in AppleScript doesn't like
non-latin encoded pathnames.


I think you're right - from dim and distant memory I seem to recall that AppleScript's '<value> as alias' coercion often doesn't work with non-ASCII paths, and you have to use an alias specifier, i.e. 'alias <value>' instead.

(The other common cause of errors is trying to create aliases for non- existent paths, of course, but I'll assume the OP already checked for that.)

Anyway, unless the OP is needing to run user-supplied scripts, I'd suggest ignoring NSAppleScript and just use a Cocoa-Apple event bridge instead.

For example, here's the objc-appscript version after using ASTranslate to get an approximate ObjC translation of the original AppleScript's Finder commands, then tweaking and tidying to suit:

	// To create glue:  osaglue  -o FIGlue  -p FI  Finder

	#import "FIGlue/FIGlue.h"

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int err = 0;

NSURL *file = [NSURL fileURLWithPath: @"/path/to/file"];

FIApplication *finder = [FIApplication applicationWithBundleID: @"com.apple.finder"];


		FIReference *ref = [[[finder items] byIndex: file] informationWindow];

		NSError *error;
		id result = [[ref open] sendWithError: &error];

		if (result)
			[[finder activate] send];
		else {
			err = [error code];
			NSLog(@"%@", [error localizedDescription]);
		}

		[pool drain];
		return err;
	}

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________

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


  • Prev by Date: Re: Crash in garbage collection, NSOpenPanel
  • Next by Date: Re: Core Data - use of simple accessors vs. KVC
  • Previous by thread: Re: NSAppleScript shies away from porcupines
  • Next by thread: is LSEnvironment working with Leopard?
  • Index(es):
    • Date
    • Thread