Instance Method

unifiedContacts(matching:keysToFetch:)

Fetches all unified contacts matching the specified predicate.

Declaration

func unifiedContacts(matching predicate: NSPredicate, keysToFetch keys: [CNKeyDescriptor]) throws -> [CNContact]

Parameters

predicate

The predicate to match against.

keys

The properties to fetch in the returned CNContact objects. You should fetch only the properties that you plan to use. Note that you can combine contact keys and contact key descriptors.

error

Error information, if an error occurred.

Return Value

An array of CNContact objects matching the predicate.

Discussion

If no matches are found, this method returns an empty array (or nil in case of error). Use only the predicates from the CNContact class predicates. Compound predicates are not supported by this method. Due to unification, the returned contacts may have different identifiers than you specify. To fetch all contacts, use enumerateContacts(with:usingBlock:).

See Also

Fetching Contacts

func enumerateContacts(with: CNContactFetchRequest, usingBlock: (CNContact, UnsafeMutablePointer<ObjCBool>) -> Void)

Returns a Boolean value that indicates whether the enumeration of all contacts matching a contact fetch request executed successfully.

func unifiedMeContactWithKeys(toFetch: [CNKeyDescriptor]) -> CNContact

Fetches the unified contact that is the "me" card.

func unifiedContact(withIdentifier: String, keysToFetch: [CNKeyDescriptor]) -> CNContact

Fetches a unified contact for the specified contact identifier.

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