---
title: "init(contentsOf:)"
framework: automator
role: symbol
role_heading: Initializer
path: "automator/amworkflow/init(contentsof:)"
---

# init(contentsOf:)

Creates and initializes a workflow based on the contents of the specified file.

## Declaration

```swift
convenience init(contentsOf fileURL: URL) throws
```

## Parameters

- `fileURL`: URL that specifies the location of a workflow file.

## Return Value

Return Value The initialized workflow object. On error, returns nil.

## Discussion

Discussion note: In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Creating a Workflow

- [init()](automator/amworkflow/init().md)
