---
title: "attributedString(from:defaultAttributes:)"
framework: contacts
role: symbol
role_heading: Instance Method
path: "contacts/cncontactformatter/attributedstring(from:defaultattributes:)"
---

# attributedString(from:defaultAttributes:)

Formats the contact name as an attributed string.

## Declaration

```swift
func attributedString(from contact: CNContact, defaultAttributes attributes: [AnyHashable : Any]? = nil) -> NSAttributedString?
```

## Parameters

- `contact`: The contact whose name is to be formatted.
- `attributes`: The default attributes to use. For more information, see doc://com.apple.documentation/documentation/Foundation/Formatter.

## Return Value

Return Value The formatted contact name as an attributed string. Discussion This method behaves similarly to string(from:style:), except that it returns an attributed string. It includes the attribute key CNContactPropertyAttribute whose attribute values are contact property keys, such as CNContactGivenNameKey. This identifies the name components in the formatted contact name.

## See Also

### Creating a formatted attributed string

- [attributedString(from:style:defaultAttributes:)](contacts/cncontactformatter/attributedstring(from:style:defaultattributes:).md)
