Instance Method

runWithInput:fromAction:error:

Requests the receiver to perform its task using the specified input from the specified action.

Declaration

- (id)runWithInput:(id)input fromAction:(AMAction *)anAction error:(NSDictionary<NSString *,id> * _Nullable *)errorInfo;

Parameters

input

The input for the receiving action. Should contain one or more objects compatible with one of the types specified in the action’s AMAccepts property.

By default, actions can only accept and provide the following types. However, by overriding this method, you can change the types your action can use:

  • Objective-C actions: Accepts and provides types must inherit from com.apple.cocoa.string, com.apple.cocoa.path, com.apple.cocoa.url, or, starting in OS X version 10.5 (v10.5), com.apple.cocoa.data.

  • Shell script actions: Accepts and provides types must inherit from com.apple.cocoa.string or, starting in OS X v10.5, com.apple.cocoa.data.

  • AppleScript actions: Accepts and provides types must inherit from com.apple.applescript.object.

anAction

The action from which the input object was obtained.

errorInfo

If an error occurs, the action returns an error dictionary in this parameter. The keys and values for this dictionary are:

  • OSAScriptErrorNumber (a string constant) — The value for this key is an instance of NSNumber whose integer value indicates an error code. See the header file MacErrors.h in the Carbon Core framework for a list of valid error codes, particularly the section on OSA errors.

  • OSAScriptErrorMessage (a string constant) —The value for this key is an instance of NSString describing the error.

For an example of how to create such a dictionary, see “Implementing runWithInput:fromAction:error:” in “Implementing an Objective-C Action" in Automator Programming Guide.

Return Value

An object containing one or more objects of a data type compatible with a type specified in the receiving action’s AMProvides property. If the receiver does not modify the data passed in input, it should return it unchanged.

Discussion

The input and output objects for actions are usually instances of NSArray. If the receiver encounters problems, it should return by indirection an error dictionary that describes the error.

This method is intended to be overridden. AppleScript actions, however, usually will not need to override this method because the same functionality is provided by an AppleScript script.

See Also

Controlling the action

- didFinishRunningWithError:

Sent by the receiver to itself when it has finished running asynchronously.

Deprecated
- finishRunningWithError:

Causes the action to stop running and return an error, which, in turn, causes the workflow to stop.

- reset

Resets the receiver to its initial state.

- runAsynchronouslyWithInput:

Causes Automator to wait for notification that the receiver has completed execution, which allows the receiver to perform an asynchronous operation.

- runWithInput:error:

Requests the receiver to perform its task using the specified input.

- stop

Stops the receiver from running.

- willFinishRunning

Invoked by Automator when the receiver has essentially completed its run phase.