Class

CNContact

An immutable object that stores information about a single contact, such as the contact's first name, phone numbers, and addresses.

Declaration

@interface CNContact : NSObject

Overview

A CNContact object stores an immutable copy of a contact's information, so you cannot change the information in this object directly. Contact objects are thread-safe, so you may access them from any thread of your app.

To modify a contact's information, call the mutableCopy method to obtain a CNMutableContact object with the same information. After modifying the mutable contact, save your changes back to the contacts database using the CNContactStore object.

Every contact in the contacts database has a unique ID, which you access using the identifier property. The mutable and immutable versions of the same contact have the same identifier.

Topics

Identifying the Contact

identifier

A value that uniquely identifies a contact on the device.

contactType

An enum identifying the contact type.

CNContactType

The types a contact can be.

Getting Name Information

namePrefix

The name prefix of the contact.

givenName

The given name of the contact.

middleName

The middle name of the contact.

familyName

The family name of the contact.

previousFamilyName

A string for the previous family name of the contact.

nameSuffix

The name suffix of the contact.

nickname

The nickname of the contact.

phoneticGivenName

The phonetic given name of the contact.

phoneticMiddleName

The phonetic middle name of the contact.

phoneticFamilyName

A string for the phonetic family name of the contact.

Getting Work Information

jobTitle

The contact’s job title.

departmentName

The name of the department associated with the contact.

organizationName

The name of the organization associated with the contact.

phoneticOrganizationName

The phonetic name of the organization associated with the contact.

Getting Addresses

postalAddresses

An array of labeled postal addresses for a contact.

emailAddresses

An array of labeled email addresses for the contact.

urlAddresses

An array of labeled URL addresses for a contact.

Getting Phone Information

phoneNumbers

An array of labeled phone numbers for a contact.

Getting Social Profiles

socialProfiles

An array of labeled social profiles for a contact.

Getting Birthday Information

birthday

A date component for the Gregorian birthday of the contact.

nonGregorianBirthday

A date component for the non-Gregorian birthday of the contact.

dates

An array containing labeled Gregorian dates.

Getting Notes

note

A string containing notes for the contact.

Getting Contact Images

imageData

The profile picture of a contact.

thumbnailImageData

The thumbnail version of the contact’s profile picture.

imageDataAvailable

A Boolean indicating whether a contact has a profile picture.

Getting Related Information

contactRelations

An array of labeled relations for the contact.

instantMessageAddresses

An array of labeled IM addresses for the contact.

Localizing Contact Data

+ localizedStringForKey:

Returns a string containing the localized contact property name.

Comparing Contacts

+ descriptorForAllComparatorKeys

Fetches all the keys required for the contact sort comparator.

+ comparatorForNameSortOrder:

Returns a comparator to sort contacts with the specified order.

- isUnifiedWithContactWithIdentifier:

Returns a Boolean indicating whether the current contact is a unified contact and includes a contact with the specified identifier.

CNContactSortOrder

Indicates the sorting order for contacts.

Checking the Availability of Data

- isKeyAvailable:

Determines whether the contact property value for the specified key is fetched.

- areKeysAvailable:

Determines whether all contact property values for the specified keys are fetched.

Getting Search Predicates

Predicates to match contacts. You can only use these predicates with CNContactStore and CNContactFetchRequest.

+ predicateForContactsMatchingName:

Returns a predicate to find the contacts matching the specified name.

+ predicateForContactsWithIdentifiers:

Returns a predicate to find the contacts matching the specified identifiers.

+ predicateForContactsInGroupWithIdentifier:

Returns a predicate to find the contacts that are members in the specified group.

+ predicateForContactsInContainerWithIdentifier:

Returns a predicate to find the contacts in the specified container.

+ predicateForContactsMatchingPhoneNumber:

Returns a predicate to find the contacts whose phone number matches the specified value.

+ predicateForContactsMatchingEmailAddress:

Returns a predicate to find the contacts whose email address matches the specified value.

Relationships

Inherits From

See Also

Contact Data

CNMutableContact

A mutable object that stores information about a single contact, such as the contact's first name, phone numbers, and addresses.

Data Objects

Access contact-related data, such as the user's postal address and phone number.

Contact Keys

Specify contact-related properties during fetch operations.

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