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

# attributedString(from:withDefaultAttributes:)

Returns a formatted postal address as an attributed string.

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

## Parameters

`postalAddress`

The postal address to format.

`attributes`

The default attributes to use. You can specify the [`CNPostalAddressPropertyAttribute`](/documentation/Contacts/CNPostalAddressPropertyAttribute) or [`CNPostalAddressLocalizedPropertyNameAttribute`](/documentation/Contacts/CNPostalAddressLocalizedPropertyNameAttribute) attributes.

## 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)