这里是如何执行程序中AppleScript的方法,假定程序包中有checknewnow.scpt这个脚本:
#define runScriptName @"checknewnow"
#define runScriptType @"scpt"
- (IBAction)runScript:(id)sender
{
NSString *scriptPath = [[NSBundle mainBundle]
pathForResource: runScriptName
ofType: runScriptType];
NSURL *scriptURL = [NSURL fileURLWithPath: scriptPath];
NSAppleScript *as = [[NSAppleScript alloc]
initWithContentsOfURL: scriptURL
error: nil];
[as executeAndReturnError: NULL];
[as release];
}