---
title: "init(contentsOf:error:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsapplescript/init(contentsof:error:)"
---

# init(contentsOf:error:)

Initializes a newly allocated script instance from the source identified by the passed URL.

## Declaration

```swift
init?(contentsOf url: URL, error errorInfo: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
```

## Parameters

- `url`: A URL that locates a script, in either text or compiled form.
- `errorInfo`: On return, if an error occurs, a pointer to an error information dictionary.

## Return Value

Return Value The initialized script object, nil if an error occurs.

## Discussion

Discussion This method is a designated initializer for NSAppleScript.

## See Also

### Related Documentation

- [Cocoa Scripting Guide](apple-archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html.md)

### Initializing a Script

- [init(source:)](foundation/nsapplescript/init(source:).md)
