NSUserAppleScriptTask Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.8 and later.
Declared in
NSUserScriptTask.h

Overview

The NSUserAppleScriptTask class is intended to run AppleScript scripts from your application. It is intended to execute user-supplied scripts and will execute them outside of the application's sandbox, if any.

The class is not intended to execute scripts built into an application; for that, use one of the NSTask classes. If the application is sandboxed, then the script must be in the NSApplicationScriptsDirectory folder. A sandboxed application may read from, but not write to, this folder.

If you simply need to execute scripts without regard to input or output, use NSUserScriptTask, which can execute any of the specific types. If you need specific control over the input to or output from the script, use this class.

Tasks

Executing an AppleScript Script

Instance Methods

executeWithAppleEvent:completionHandler:

Execute the AppleScript script by sending it the specified Apple event.

- (void)executeWithAppleEvent:(NSAppleEventDescriptor *)event completionHandler:(NSUserAppleScriptTaskCompletionHandler)handler
Parameters
event

The Apple event.

handler

The completion handler Block that returns the result or an error. See NSUserAppleScriptTaskCompletionHandler.

Discussion

Pass nil as event to execute the script's default "run" handler.

This method should be invoked no more than once for a given instance of the class.

If the script completed normally, the completion handler's error parameter will be nil.

Availability
  • Available in OS X v10.8 and later.
See Also
Declared In
NSUserScriptTask.h

Constants

NSUserAppleScriptTaskCompletionHandler

Implement this block to retrieve the result of the AppleScript executed by executeWithAppleEvent:completionHandler:.

typedef void (^NSUserAppleScriptTaskCompletionHandler)(NSAppleEventDescriptor *result, NSError *error);
Availability
  • Available in OS X v10.8 and later.
Declared In
NSUserScriptTask.h