Type Method


Formats the contact name as an attributed string.


class func attributedString(from contact: CNContact, style: CNContactFormatterStyle, defaultAttributes attributes: [AnyHashable : Any]? = nil) -> NSAttributedString?



The contact whose name is to be formatted.


The formatting style to be used for the contact name.


The default attributes to use. For more information, see Formatter.

Return Value

The formatted contact name as an attributed string.


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

See Also

Creating a Formatted Attributed String

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software