Applescript和Cocoa

时间:2011-11-13 13:21:43

标签: cocoa applescript

我想在AppleScript的cocoa app中调用IBAction:

我想打电话:

    - (IBAction)reverse:(id)pId;
    {
        direction = -1;

    } 

在外部AppleScript文件中添加一行,如:

    tell application "theapp"
    reverse
    end tell

任何想法?

先谢谢

1 个答案:

答案 0 :(得分:1)

使用NSAppleScript。

NSAppleScript *as = [[NSAppleScript alloc] initWithSource:@"tell application \"theapp\"\nreverse\nend tell"];
NSDictionary *err = nil;
NSAppleEventDescriptor *desc = [as executeAndReturnError:&err];
NSLog(@"Error: %@\nData: %@", err, desc.data);
[as release];

Scripting Bridge here

也有一个很好的答案