AMWorkflowController Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Automator.framework
Availability
Available in OS X v10.5 and later.
Declared in
AMWorkflowController.h
Companion guides
Related sample code

Overview

The AMWorkflowController class lets you manage an Automator workflow in your application. You use the AMWorkflow class to instantiate a workflow and an instance of AMWorkflowView to display it.

A controller can run and stop a workflow and obtain information about its state. The controller’s delegate can receive messages as the workflow is executed and its actions are run.

You can load and run a workflow with minimal overhead by using the AMWorkflow class method runWorkflowAtURL:withInput:error:. When you use AMWorkflowController, you get more control of the process, but there’s more work, as you must create and initialize both the workflow and the workflow controller objects.

A 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 a workflow.

Tasks

Accessing the Workflow

Accessing the Workflow View

Accessing the Delegate

Controlling the Workflow

Running an Action in the Workflow

Errors Messages

Instance Methods

canRun

Returns a Boolean value that indicates whether the receiver's workflow is able to run.

- (BOOL)canRun
Return Value

YES if the controller’s workflow is able to run; NO otherwise.

Discussion

You might use this method to determine when to enable a “Run” button or other UI element you use to run the workflow.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

delegate

Returns the receiver's delegate.

- (id)delegate
Return Value

The controller’s delegate.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

isRunning

Returns a Boolean value that indicates whether the receiver's workflow is currently running.

- (BOOL)isRunning
Return Value

YES if the controller’s workflow is currently running; NO otherwise.

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
AMWorkflowController.h

run:

Runs the associated workflow, after first clearing any results stored by its actions during any previous run.

- (IBAction)run:(id)sender
Parameters
sender

Object that initiated the run action.

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
AMWorkflowController.h

setDelegate:

Sets the receiver's delegate.

- (void)setDelegate:(id)delegate
Parameters
delegate

The delegate object to set. This object will receive updates on the progress and state of the workflow controller.

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
AMWorkflowController.h

setWorkflow:

Sets the receiver's workflow.

- (void)setWorkflow:(AMWorkflow *)workflow
Parameters
workflow

A workflow object.

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
AMWorkflowController.h

setWorkflowView:

Sets the receiver's workflow view.

- (void)setWorkflowView:(AMWorkflowView *)view
Parameters
view

A workflow view object.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

stop:

Stops the associated workflow.

- (IBAction)stop:(id)sender
Parameters
sender

Object that initiated the stop action.

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
AMWorkflowController.h

workflow

Returns the receiver's workflow.

- (AMWorkflow *)workflow
Return Value

The controller’s workflow.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowView

Returns the receiver's workflow view.

- (AMWorkflowView *)workflowView
Return Value

The controller’s workflow view.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

Delegate Methods

workflowController:didError:

Invoked when the receiver's workflow encounters an error.

- (void)workflowController:(AMWorkflowController *)controller didError:(NSError *)error
Parameters
controller

The controller object sending the message.

error

If a workflow error occurs, upon return contains an instance of NSError that describes the problem.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowController:didRunAction:

Invoked when an action in the receiver's workflow is finished running.

- (void)workflowController:(AMWorkflowController *)controller didRunAction:(AMAction *)action
Parameters
controller

The controller object sending the message.

action

The workflow action that ran.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowController:willRunAction:

Invoked when an action in the receiver's workflow is about to run.

- (void)workflowController:(AMWorkflowController *)controller willRunAction:(AMAction *)action
Parameters
controller

The controller object sending the message.

action

The workflow action that will run.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowControllerDidRun:

Invoked after the workflow is run.

- (void)workflowControllerDidRun:(AMWorkflowController *)controller
Parameters
controller

The controller object sending the message.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowControllerDidStop:

Invoked after the workflow stops.

- (void)workflowControllerDidStop:(AMWorkflowController *)controller
Parameters
controller

The controller object sending the message.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowControllerWillRun:

Invoked when the workflow is about to run.

- (void)workflowControllerWillRun:(AMWorkflowController *)controller
Parameters
controller

The controller object sending the message.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h

workflowControllerWillStop:

Invoked when the workflow is about to stop.

- (void)workflowControllerWillStop:(AMWorkflowController *)controller
Parameters
controller

The controller object sending the message.

Availability
  • Available in OS X v10.5 and later.
Declared In
AMWorkflowController.h