Quinn,
This is about as simple of an example as I can provide:
An ApplescriptObjC automator action project in Xcode. The Interface builder provides an Automator Path Pop Up Button that allows the user to select an existing workflow to be run. The code to implement the action is shown below.
------------------------------ Applescript code for automator action ---------------------------------
script Run_Workflow_on_Each_Job -- this the File's Owner in IB
property parent : class "AMBundleAction"
property pWFController : missing value -- connected to AMWorkflowController instance in IB
property pWorkflow : missing value -- assigned here
property pWFView : missing value -- assigned here
property pWorkflowPath : "" -- posix path to workflow specified by user in GUI
on runWithInput_fromAction_error_(input, anAction, errorRef)
try
-- set up workflow
set paramRec to parameters() as record
set pWorkflowPath to |workflowPath| of paramRec
set wfURL to current application's NSURL's fileURLWithPath_isDirectory_(pWorkflowPath, false)
set myErr to current application's NSError's errorWithDomain_code_userInfo_(current application's NSCocoaErrorDomain, 1, {localizedDescription:"Error", code:0})
tell current application's AMWorkflow to set pWorkflow to alloc()'s initWithContentsOfURL_error_(wfURL, a reference to myErr)
if pWorkflow is missing value then
error "Could not initialize workflow"
end if
-- set up the controller
tell pWFController
setDelegate_(me)
setWorkflow_(pWorkflow)
setWorkflowView_(pWFView) -- this is hidden
end tell
set theJob to input
tell pWorkflow to setInput_(theJob)
tell pWFController
run_(me)
end tell
return input -- for test
on error errMsg number errNum
set contents of errorRef to {OSAScriptErrorNumberKey:errNum, OSAScriptErrorMessageKey:errMsg}
return missing value
end try
end runWithInput_fromAction_error_
end script
--------------------------------- end of sample code ----------------------------------
Thanks,
Steve