---
title: "init(URL:documentAttributes:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsattributedstring/init(url:documentattributes:)"
---

# init(URL:documentAttributes:)

Initializes a new attributed string object from the data at the specified URL.

## Declaration

```swift
init?(URL url: URL, documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
```

```swift
init?(url: URL, documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
```

## Parameters

- `url`: An NSURL object specifying the document to load.
- `dict`: An in-out dictionary containing document-level attributes described in Document Attributes. May be NULL, in which case no document attributes are returned.

## Return Value

Return Value Returns an initialized object, or nil if the data can’t be decoded.

## Discussion

Discussion The contents of aURL are examined to best load the file in whatever format it’s in. Filter services can be used to convert the file into a format recognized by Cocoa. Also returns by reference in docAttributes a dictionary containing document-level attributes described in Document Attributes. docAttributes may be NULL, in which case no document attributes are returned. Returns an initialized object, or nil if the file at path can’t be decoded.

## See Also

### Deprecated Initializers

- [init(path:documentAttributes:)](foundation/nsattributedstring/init(path:documentattributes:).md)
- [init(fileURL:options:documentAttributes:)](foundation/nsattributedstring/init(fileurl:options:documentattributes:).md)
