如何将字符串从Applescript传递到Objective C

Fer*_*tes 3 cocoa applescript objective-c

我工作的一个应用程序,我需要能够传递一个字符串变量AppleScript的目标C.我已经想出了如何从我的Objective C类中的方法运行Applescript,但是我需要能够将一个NSString设置为来自Applescript的字符串.我怎么能做到这一点?

提前致谢!

Ann*_*nne 7

快速举例:

NSString *theScript =   @"set theTimeString to time string of (current date)\n"
                         "return theTimeString";

NSDictionary *errorInfo = nil;
NSAppleScript *run = [[NSAppleScript alloc] initWithSource:theScript];
NSAppleEventDescriptor *theDescriptor = [run executeAndReturnError:&errorInfo];
NSString *theResult = [theDescriptor stringValue];
NSLog(@"%@",theResult);
Run Code Online (Sandbox Code Playgroud)

输出:

下午2:36:06