Josh
Josh

Reputation: 104

Applescript and Cocoa

I would like to call a IBAction within a cocoa app from applescript:

I want to call:

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

    } 

with a line in an external applescript file like:

    tell application "theapp"
    reverse
    end tell

Any Ideas?

Thanks in Advance

Upvotes: 0

Views: 246

Answers (1)

Alex Zielenski
Alex Zielenski

Reputation: 3601

Use 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];

There is also a good answer about Scripting Bridge here

Upvotes: 1

Related Questions