| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Automator.framework |
| Availability | Available in Mac OS X v10.5 and later.
|
| Declared in | AMWorkflow.h |
| Companion guides |
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.
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 runWorkflowAtURL:withInput:error:. 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.
Loads and runs the specified workflow file.
+ (id)runWorkflowAtURL:(NSURL *)fileURL withInput:(id)input error:(NSError **)error
URL that specifies the location of a workflow file.
Specifies the input for the first action in the workflow. Pass nil if the first action doesn’t need input.
If no workflow is found or if an error occurs in initializing or running it, upon return contains an instance of NSError that describes the problem.
On error, returns nil. Otherwise, returns the output of the last action in the workflow. Your application may need to convert the data to a desired type.
Use this method to run a workflow without the overhead of performing a separate allocation, setting up a workflow controller, and so on. However, in situations where you need greater control, such as the ability to start and stop the workflow, use an instance of the AMWorkflowController class instead.
The workflow is run in a separate process so that any actions it contains are executed in a separate memory space. This helps to insulate the application from crashes, memory leaks, or exceptions that might occur from running the actions in the workflow.
AMWorkflow.hReturns an array of the workflow’s actions.
- (NSArray *)actions
An array of actions for the workflow file. Actions are instances of classes such as AMBundleAction, AMAppleScriptAction, and AMShellScriptAction.
AMWorkflow.hAdds the specified action at the end of the receiving workflow.
- (void)addAction:(AMAction *)action
The action to add.
The workflow retains the action but does not copy it.
AMWorkflow.hReturns a URL that specifies the location of the workflow file.
- (NSURL *)fileURL
URL that specifies the location of the workflow file.
AMWorkflow.hCreates and initializes a workflow based on the contents of the specified file.
- (id)initWithContentsOfURL:(NSURL *)fileURL error:(NSError **)outError
URL that specifies the location of a workflow file.
If the workflow file can’t be found, or if an error occurs in initializing the workflow, upon return contains an instance of NSError that describes the problem.
The initialized workflow object. On error, returns nil.
AMWorkflow.hReturns the input data that is passed to the first action in the workflow.
- (id)input
The input for the first action in the workflow. Should be a data type the action can use, or a type that can be converted to one the action can use.
AMWorkflow.hInserts the specified action at the specified position of the receiving workflow.
- (void)insertAction:(AMAction *)action atIndex:(NSUInteger)index
The action to insert.
The position in the receiver at which to insert the action. If the position is invalid, this method does nothing.
The workflow retains the action but does not copy it.
AMWorkflow.hMoves the action from the specified start position to the specified end position in the receiving workflow.
- (void)moveActionAtIndex:(NSUInteger)startIndex toIndex:(NSUInteger)endIndex
The start position of the action to move.
The end position for the action that is moved.
If either index is invalid, this method does nothing.
AMWorkflow.hRemoves the specified action from the receiver.
- (void)removeAction:(AMAction *)action
The action to be removed.
The action receives an AMAction closed message before being released.
AMWorkflow.hSets the input data that is passed to the first action in the workflow.
- (void)setInput:(id)input
The input for the first action in the workflow. Should be a data type the action can use, or a type that can be converted to one the action can use.
AMWorkflow.hSets the value of the workflow variable with the specified name.
- (BOOL)setValue:(id)value forVariableWithName:(NSString *)variableName
The value to set for the named variable.
The name of a variable to set the value for.
YES if variableName was found and its value set; otherwise NO.
This method does nothing if the variable specified by variableName is not found.
AMWorkflow.hReturns the value of the workflow variable with the specified name.
- (id)valueForVariableWithName:(NSString *)variableName
The variable name.
The value for the variable. Returns nil if no variable is found with the specified name.
AMWorkflow.hWrites the workflow to the specified file.
- (BOOL)writeToURL:(NSURL *)fileURL error:(NSError **)outError
URL that specifies the file location to write the workflow to.
If the workflow file can’t be written, upon return contains an instance of NSError that describes the problem.
YES if the workflow was successfully written; otherwise NO.
You might want to save the workflow, for example, because you have made changes to a variable it contains.
AMWorkflow.h
Last updated: 2006-10-26