attributedString(from:withDefaultAttributes:)
Returns a formatted postal address as an attributed string.
Declaration
func attributedString(from postalAddress: CNPostalAddress, withDefaultAttributes attributes: [AnyHashable : Any] = [:]) -> NSAttributedStringParameters
- postalAddress:
The postal address to format.
- attributes:
The default attributes to use. You can specify the Cnpostaladdresspropertyattribute or Cnpostaladdresslocalizedpropertynameattribute attributes.
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.