---
title: NSAttributedString.CompletionHandler
framework: foundation
role: symbol
role_heading: Type Alias
path: foundation/nsattributedstring/completionhandler
---

# NSAttributedString.CompletionHandler

A completion handler for getting an asynchronous attributed string.

## Declaration

```swift
typealias CompletionHandler = (NSAttributedString?, [NSAttributedString.DocumentAttributeKey : Any]?, (any Error)?) -> Void
```

## Parameters

- `attributedString`: The attributed string, or nil if the method couldn’t create the string.
- `attributes`: A dictionary containing document-level attributes. This parameter is nil if the document doesn’t have any attributes.
- `error`: An error object if an error occurred, or nil if the method returned the string successfully.

## See Also

### Creating from HTML

- [init(HTML:documentAttributes:)](foundation/nsattributedstring/init(html:documentattributes:).md)
- [init(HTML:baseURL:documentAttributes:)](foundation/nsattributedstring/init(html:baseurl:documentattributes:).md)
- [init(HTML:options:documentAttributes:)](foundation/nsattributedstring/init(html:options:documentattributes:).md)
- [loadFromHTML(request:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(request:options:completionhandler:).md)
- [loadFromHTML(fileURL:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(fileurl:options:completionhandler:).md)
- [loadFromHTML(string:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(string:options:completionhandler:).md)
- [loadFromHTML(data:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(data:options:completionhandler:).md)
