Instance Method

unifiedContactsMatchingPredicate:keysToFetch:error:

Fetches all unified contacts matching the specified predicate.

Declaration

- (NSArray<CNContact *> *)unifiedContactsMatchingPredicate:(NSPredicate *)predicate keysToFetch:(NSArray<id<CNKeyDescriptor>> *)keys error:(NSError * _Nullable *)error;

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 enumerateContactsWithFetchRequest:error:usingBlock:.

See Also

Fetching Contacts

- enumerateContactsWithFetchRequest:error:usingBlock:

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

- unifiedMeContactWithKeysToFetch:error:

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

- unifiedContactWithIdentifier:keysToFetch:error:

Fetches a unified contact for the specified contact identifier.