Mac Developer Library

Developer

Automator Framework Reference AMWorkflowController Class Reference

Options
Deployment Target:

On This Page
Language:

AMWorkflowController

Inheritance


Conforms To


Import Statement


Swift

import Automator

Objective-C

@import Automator;

Availability


Available in OS X v10.5 and later.

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.

  • workflow workflow Property

    Returns the receiver's workflow.

    Declaration

    Swift

    var workflow: AMWorkflow!

    Objective-C

    @property(strong) AMWorkflow *workflow

    Return Value

    The controller’s workflow.

    Discussion

    Use setWorkflow: to set the receiver’s workflow.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Returns the receiver's workflow view.

    Declaration

    Swift

    var workflowView: AMWorkflowView!

    Objective-C

    @property(strong) AMWorkflowView *workflowView

    Return Value

    The controller’s workflow view.

    Discussion

    Use setWorkflowView: to set the receiver’s workflow.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • delegate delegate Property

    Returns the receiver's delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: AnyObject!

    Objective-C

    @property(assign) id delegate

    Return Value

    The controller’s delegate.

    Discussion

    Use setDelegate: to set the receiver’s delegate object. This object will receive updates on the progress and state of the workflow controller.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Pauses a workflow that is running.

    Declaration

    Swift

    @IBAction func pause(_ sender: AnyObject!)

    Objective-C

    - (IBAction)pause:(id)sender

    Parameters

    sender

    Object that initiated the pause action.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.7 and later.

  • Stops a workflow, clears any action results, and resets the workflow back to an un-run state.

    Declaration

    Swift

    @IBAction func reset(_ sender: AnyObject!)

    Objective-C

    - (IBAction)reset:(id)sender

    Parameters

    sender

    Object that initiated the reset action.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    @IBAction func run(_ sender: AnyObject!)

    Objective-C

    - (IBAction)run:(id)sender

    Parameters

    sender

    Object that initiated the run action.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • In a paused workflow, runs the next action in the workflow and then pauses again.

    Declaration

    Swift

    @IBAction func step(_ sender: AnyObject!)

    Objective-C

    - (IBAction)step:(id)sender

    Parameters

    sender

    Object that initiated the step action.

    Discussion

    Stepping allows a workflow to be executed one action at a time. This is useful for ensuring that the workflow is doing what it’s supposed to do, as the results of each individual action can be inspected before moving on to the next.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.7 and later.

  • Stops the associated workflow.

    Declaration

    Swift

    @IBAction func stop(_ sender: AnyObject!)

    Objective-C

    - (IBAction)stop:(id)sender

    Parameters

    sender

    Object that initiated the stop action.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Invoked when the workflow is about to run.

    Declaration

    Swift

    func workflowControllerWillRun(_ controller: AMWorkflowController!)

    Objective-C

    - (void)workflowControllerWillRun:(AMWorkflowController *)controller

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Invoked after the workflow is run.

    Declaration

    Swift

    func workflowControllerDidRun(_ controller: AMWorkflowController!)

    Objective-C

    - (void)workflowControllerDidRun:(AMWorkflowController *)controller

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Invoked when the workflow is about to stop.

    Declaration

    Swift

    func workflowControllerWillStop(_ controller: AMWorkflowController!)

    Objective-C

    - (void)workflowControllerWillStop:(AMWorkflowController *)controller

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Invoked after the workflow stops.

    Declaration

    Swift

    func workflowControllerDidStop(_ controller: AMWorkflowController!)

    Objective-C

    - (void)workflowControllerDidStop:(AMWorkflowController *)controller

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • canRun canRun Property

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

    Declaration

    Swift

    var canRun: Bool { get }

    Objective-C

    @property(readonly) BOOL canRun

    Return Value

    YEStrue if the controller’s workflow is able to run; NOfalse 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.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

    See Also

    running

  • paused paused Property

    A Boolean value that indicates whether the receiver's workflow is currently paused. (read-only)

    Declaration

    Swift

    var paused: Bool { get }

    Objective-C

    @property(getter=isPaused, readonly) BOOL paused

    Return Value

    YEStrue if the controller’s workflow is currently paused; NOfalse otherwise.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.10 and later.

    See Also

    canRun

  • running running Property

    A Boolean value that indicates whether the receiver's workflow is currently running. (read-only)

    Declaration

    Swift

    var running: Bool { get }

    Objective-C

    @property(getter=isRunning, readonly) BOOL running

    Discussion

    YEStrue if the controller’s workflow is currently running; NOfalse otherwise. Use isRunning: to determine whether the receiver's workflow is currently running.

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.10 and later.

    See Also

    canRun

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

    Declaration

    Swift

    func workflowController(_ controller: AMWorkflowController!, didRunAction action: AMAction!)

    Objective-C

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

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    func workflowController(_ controller: AMWorkflowController!, willRunAction action: AMAction!)

    Objective-C

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

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.

  • Invoked when the receiver's workflow encounters an error.

    Declaration

    Swift

    func workflowController(_ controller: AMWorkflowController!, didError error: NSError!)

    Objective-C

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

    Import Statement

    Objective-C

    @import Automator;

    Swift

    import Automator

    Availability

    Available in OS X v10.5 and later.