Contents

attributedString(from:style:withDefaultAttributes:)

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

Declaration

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.

  • 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:), except that it returns an attributed string. It includes the attribute key CNPostalAddressPropertyAttribute, whose attribute values are postal address property keys, such as CNPostalAddressStreetKey. This identifies the postal address components in the formatted postal address. It also includes the attribute key CNPostalAddressLocalizedPropertyNameAttribute whose attribute values are the localized strings for the postal address property keys.

See Also

Generating a formatted attributed string