Cocoa AppleScript
Cocoa AppleScript
- Subject: Cocoa AppleScript
- From: John Nairn <email@hidden>
- Date: Tue, 02 Aug 2011 09:04:20 -0700
I have always run AppleScripts with a single Cocoa call:
NSAppleEventDescriptor *result=[script executeAndReturnError:&errorInfo];
but things seemed to have change in Lion. The first symptom is that scripts that used to run fine, now quit with an "AppleEvent timed out" error. The only one that is causing problems now is simply to open a file in a Script:
open file GEDFilePath
This task times out immediately without waiting the 120 seconds (which is supposed to be default AppleEvent time out time) and despite the fact the the file successfully opens even after the script has quit. My Cocoa code to open a file does the following. The document class responds to
- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)aType error:(NSError **)outError
The first task is to detach a thread to read the file:
[NSThread detachNewThreadSelector:@selector(readFileThread:)
toTarget:self
withObject:[NSArray arrayWithObjects:fileName,aType,nil]];
The main thread then enters a modal progress panel to display opening progress and to have a button to cancel the process if desired:
showProgress = (allocate and retain my ProgressController window)
NSTimeInterval frameRate = 1./3.;
[showProgress runModalProgress:frameRate];
[[showProgress window] close];
[showProgress release];
showProgress = nil;
This same code works fine in 10.4 through 10.6. In Lion the read process works fine but times out immediately when called from AppleScript.
------------
John Nairn
http://www.geditcom.com
Genealogy Software for the Mac
_______________________________________________
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