Instance Method

runAsynchronously(withInput:)

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

Declaration

func runAsynchronously(withInput input: Any?)

Parameters

input

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

Discussion

This method is intended to be overridden only by actions that need to make asynchronous calls. After runAsynchronouslyWithInput: is invoked, Automator does not continue until the action invokes finishRunningWithError(_:). So in your override of this method, you can make an asynchronous call, wait to be notified of its completion, then invoke finishRunningWithError(_:) to signal to Automator that the action has completed.

For actions that do not need to make asynchronous calls, the preferred method is runWithInput:fromAction:error:.

See Also

Controlling the action

func finishRunningWithError(Error?)

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

func reset()

Resets the receiver to its initial state.

func run(withInput: Any?) -> Any

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

func stop()

Stops the receiver from running.

func willFinishRunning()

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