The AMWorkflow class lets you use an Automator workflow in your application. You can display a workflow with an instance of AMWorkflowView and control its operation with an instance of AMWorkflowController.


class AMWorkflow : NSObject


A workflow consists of one or more actions (discrete tasks), which together can perform complex automation tasks. Your application can use workflows to package its own features and to take advantage of features provided by other applications. You create actions with Xcode, while you create workflows with the Automator application.

You can load and run a workflow with minimal overhead by using the AMWorkflow class method run(at:withInput:). However, in situations where you need greater control, such as the ability to start and stop the workflow, you can use an instance of the AMWorkflowController class instead. In that case, you’ll have to create and initialize both a workflow and a workflow controller object.

In either case, the workflow is run in a separate process so that any actions it contains are executed in a separate memory space. That helps to insulate your application from crashes, memory leaks, or exceptions that might occur from running the actions in the workflow.


Running a specified workflow

class func run(at: URL, withInput: Any?) -> Any

Loads and runs the specified workflow file.

Creating and initializing a workflow

init(contentsOf: URL)

Creates and initializes a workflow based on the contents of the specified file.

Saving changes to a workflow

func write(to: URL)

Writes the workflow to the specified file.

Getting information about the workflow

var actions: [AMAction]

Returns an array of the workflow’s actions.

var fileURL: URL?

Returns a URL that specifies the location of the workflow file.

func valueForVariable(withName: String) -> Any?

Returns the value of the workflow variable with the specified name.

Working with the workflow’s input and output

var input: Any?

Returns the input data that is passed to the first action in the workflow.

var output: Any?

Returns the output data that is provided by the last action in the workflow.

Manipulating the workflow

func setValue(Any?, forVariableWithName: String) -> Bool

Sets the value of the workflow variable with the specified name.

Manipulating the workflow’s actions

func addAction(AMAction)

Adds the specified action at the end of the receiving workflow.

func insertAction(AMAction, at: Int)

Inserts the specified action at the specified position of the receiving workflow.

func moveAction(at: Int, to: Int)

Moves the action from the specified start position to the specified end position in the receiving workflow.

func removeAction(AMAction)

Removes the specified action from the receiver.



Inherits From