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 Unified Contacts

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.