<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Contacts",
  "identifier" : "/documentation/Contacts/CNContactFormatter/attributedString(from:defaultAttributes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Contacts"
    ],
    "preciseIdentifier" : "c:objc(cs)CNContactFormatter(im)attributedStringFromContact:defaultAttributes:"
  },
  "title" : "attributedString(from:defaultAttributes:)"
}
-->

# attributedString(from:defaultAttributes:)

Formats the contact name as an attributed string.

```
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

The formatted contact name as an attributed string.

## Discussion

This method behaves similarly to [`string(from:style:)`](/documentation/Contacts/CNContactFormatter/string(from:style:)), except that it returns an attributed string. It includes the attribute key [`CNContactPropertyAttribute`](/documentation/Contacts/CNContactPropertyAttribute) whose attribute values are contact property keys, such as [`CNContactGivenNameKey`](/documentation/Contacts/CNContactGivenNameKey). This identifies the name components in the formatted contact name.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)