<!--
{
  "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/CNPostalAddressFormatter/attributedString(from:style:withDefaultAttributes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Contacts"
    ],
    "preciseIdentifier" : "c:objc(cs)CNPostalAddressFormatter(cm)attributedStringFromPostalAddress:style:withDefaultAttributes:"
  },
  "title" : "attributedString(from:style:withDefaultAttributes:)"
}
-->

# attributedString(from:style:withDefaultAttributes:)

Returns a postal address as an attributed string and formatted for the specified style.

```
class func attributedString(from postalAddress: CNPostalAddress, style: CNPostalAddressFormatterStyle, withDefaultAttributes attributes: [AnyHashable : Any] = [:]) -> NSAttributedString
```

## Parameters

`postalAddress`

The postal address to format.

`style`

The postal formatting style to use. For a list of possible values, see [`CNPostalAddressFormatterStyle`](/documentation/Contacts/CNPostalAddressFormatterStyle).

`attributes`

The default attributes to use. To learn more, see Formatter.

## Return Value

The formatted postal address as an attributed string.

## Discussion

This method behaves similarly to  [`string(from:)`](/documentation/Contacts/CNPostalAddressFormatter/string(from:)), except that it returns an attributed string. It includes the attribute key [`CNPostalAddressPropertyAttribute`](/documentation/Contacts/CNPostalAddressPropertyAttribute), whose attribute values are postal address property keys, such as [`CNPostalAddressStreetKey`](/documentation/Contacts/CNPostalAddressStreetKey). This identifies the postal address components in the formatted postal address. It also includes the attribute key [`CNPostalAddressLocalizedPropertyNameAttribute`](/documentation/Contacts/CNPostalAddressLocalizedPropertyNameAttribute) whose attribute values are the localized strings for the postal address property keys.

---

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)