AMAction Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Automator.framework |
| Availability | Available in OS X v10.4 and later. |
| Companion guide | |
| Declared in | AMAction.h |
Overview
AMAction is an abstract class that defines the interface and general characteristics of Automator actions. Automator is an Apple-provided application that allows users to construct and execute workflows consisting of a sequence of discrete modules called actions. An action performs a specific task, such as copying a file or cropping an image, and passes its output to Automator to give to the next action in the workflow. Actions are currently implemented as loadable bundles owned by objects of the AMBundleAction class, a subclass of AMAction.
The critically important method declared by AMAction is runWithInput:fromAction:error:. When Automator executes a workflow, it sends this message to each action object in the workflow (in workflow sequence), in most cases passing in the output of the previous action as input. The action object performs its task in this method and ends by returning an output object for the next action in the workflow.
Subclassing Notes
Subclassing AMAction is not recommended. For most situations requiring an enhancement to the Automator framework, it is sufficient to subclass AMBundleAction or one of its public subclasses, AMAppleScriptAction or AMShellScriptAction.
Tasks
Initialization and Encoding
-
– initWithDefinition:fromArchive: -
– initWithContentsOfURL:error: -
– writeToDictionary: -
– definitionDeprecated in OS X v10.4
Controlling the Action
-
– reset -
– runAsynchronouslyWithInput: -
– stop -
– runWithInput:fromAction:error:Deprecated in OS X v10.4
Initializing and Synchronizing the Action User Interface
Updating Action Parameters
Getting Information About the Action
-
– closed -
– ignoresInput -
– name -
– output -
– willFinishRunning -
– didFinishRunningWithError:Deprecated in OS X v10.5
Instance Methods
activated
Invoked when the window of the Automator workflow to which the receiver belongs becomes the main window. This allows the receiver to synchronize its information with settings in another application.
Discussion
Be sure to invoke the superclass implementation of this method as the last thing in your implementation.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.hclosed
Invoked by Automator when the receiving action is removed from a workflow, allowing it to perform cleanup operations.
Discussion
This method is intended to be overridden, so that your action can perform its specific cleanup operations.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hignoresInput
Returns a Boolean value that indicates whether the action acts upon its input or the input is ignored.
Return Value
YES if the action acts upon its input, otherwise NO.
Discussion
Many actions act upon their input, but an action may merely pass on its input or, rarely, ignore it.
Special Considerations
Although this method was documented in OS X version 10.4, and an action would respond to this message, the method was not made public, and using it would generate a warning in Xcode.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hinitWithContentsOfURL:error:
Loads an Automator action from a file URL.
Parameters
- fileURL
URL that specifies the location of an action file.
- outError
If no action is found or if an error occurs in initializing or running it, upon return contains an instance of
NSErrorthat describes the problem. For keys and error constants used with action errors, see Automator Constants Reference.
Return Value
The initialized action.
Discussion
This method is typically invoked by applications that use the AMWorkflow class to embed Automator workflows. It is used to allow creation of actions for a workflow.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hinitWithDefinition:fromArchive:
Initializes the receiver with the specified definition.
Parameters
- dict
Describes the action, including any custom definition properties.
- archived
If the receiver is being unarchived,
YES, otherwiseNO.
Return Value
The initialized action.
Discussion
This is the primary initializer for all Automator classes. The Automator application sends this message to instances of AMAction both when it loads actions bundles and when it unarchives them.
The AMAction object being instantiated should perform whatever initializations are necessary after invoking super’s implementation of this method. It can then examine the values in dict, particularly if the receiver had been archived with custom definition properties.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.hname
Returns the name of the action.
Return Value
The name of the receiving action.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hopened
Invoked when the receiver is first added to a workflow, allowing it to initialize its user interface.
Discussion
You should perform all initializations of an action’s user interface in this method and not in awakeFromNib. Be sure to invoke the superclass implementation of this method as the final step of your implementation.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.houtput
Returns the receiver’s output.
Return Value
The receiving action’s output, or nil if called before the action is run.
Discussion
This method is used in conjunction with the AMWorkflow class, which allows access to the actions in a workflow. Within a workflow, for example, you might iteratively inspect the output of each action. Or, on completion of a workflow, you might examine the output of the last action, to determine the output of the workflow.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hparametersUpdated
Requests the receiver to update its user interface from its stored parameters, which have changed.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.hreset
Resets the receiver to its initial state.
Discussion
Resetting causes the action to release its output generated from the current execution of the workflow.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.hrunAsynchronouslyWithInput:
Causes Automator to wait for notification that the receiver has completed execution, which allows the receiver to perform an asynchronous operation.
Parameters
- input
The input for the action. Should contain one or more objects compatible with one of the types specified in the action’s
AMAcceptsproperty.
Discussion
This method should be overridden only by actions that need to make asynchronous calls. After runAsynchronouslyWithInput: is invoked, Automator does not continue until the action invokes didFinishRunningWithError:. So in your override of this method, you can make an asynchronous call, wait to be notified of its completion, then invoke didFinishRunningWithError: 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:.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hstop
Stops the receiver from running.
Discussion
The output acquired by the action during execution of the current workflow is still accessible to Automator.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.hupdateParameters
Requests the receiver to update its stored set of parameters from the settings in the action’s user interface.
Discussion
This message is sent just before an action is saved, copied, or run. Preferably, an action’s settings should not solely reside in the controls of its view, but if they do, the action can fetch and save them in this method.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.hwillFinishRunning
Invoked by Automator when the receiver has essentially completed its run phase.
Discussion
This method is intended to be overridden. An action can use this method to perform cleanup operations, such as closing windows and deallocating memory.
Availability
- Available in OS X v10.5 and later.
Declared In
AMAction.hwriteToDictionary:
Examines the parameters and other configuration information specified in the passed dictionary and add its own information to it if appropriate.
Parameters
- dictionary
Possibly contains parameter and other configuration information about the receiver.
Discussion
Automator sends this message to an action object prior to archiving it. In its implementation of this method, the action object should first invoke the superclass implementation.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
AMAction.h© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-01)