Class

CNContactViewController

The CNContactViewController class implements the view to display a contact. CNContactViewController can display a new contact, unknown contact, or existing contact. You must use one of the designated initializers from init(forNewContact:), init(forUnknownContact:), or init(for:) respectively.

Declaration

iOS
class CNContactViewController : UIViewController
macOS
class CNContactViewController : NSViewController

Topics

Required Keys

class func descriptorForRequiredKeys() -> CNKeyDescriptor

Returns the descriptor for all the keys that must be fetched on the contact before setting it on the view controller.

Initializing View Controllers

init(for: CNContact)

Initializes a view controller for an existing contact.

init(forUnknownContact: CNContact)

Initializes a view controller for an unknown contact.

init(forNewContact: CNContact?)

Initializes a view controller for a new contact.

Displaying Contact Properties

var contact: CNContact

The contact being displayed.

var parentGroup: CNGroup?

Specifies the group to which to add the new contact.

var alternateName: String?

The name to use if the contact has no display name.

var message: String?

The message to displayed under the name.

var displayedPropertyKeys: [Any]?

The CNContact property keys to be displayed.

Notifying Delegate

Contact Store

var contactStore: CNContactStore?

The contact store from which the contact was fetched or to which it will be saved.

Customizing Contact Card

var allowsEditing: Bool

Determines whether the user can edit the contact’s information.

var allowsActions: Bool

Determines whether to display buttons for actions such as sending a text message or initiating a FaceTime call.

var shouldShowLinkedContacts: Bool

Determines whether to display data from contacts that are linked to the contact being displayed.

Highlighting a Property

func highlightProperty(withKey: String, identifier: String?)

Highlights the property of the contact being displayed.