---
title: "unifiedContacts(matching:keysToFetch:)"
framework: contacts
role: symbol
role_heading: Instance Method
path: "contacts/cncontactstore/unifiedcontacts(matching:keystofetch:)"
---

# unifiedContacts(matching:keysToFetch:)

Fetches all unified contacts matching the specified predicate.

## Declaration

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

## Parameters

- `predicate`: The predicate to match against.
- `keys`: The properties to fetch in the returned doc://com.apple.contacts/documentation/Contacts/CNContact objects. Fetch only the properties that your app uses. You can combine contact keys and contact key descriptors.

## Return Value

Return Value An array of CNContact objects matching the predicate. Discussion If the system doesn’t find any matches, this method returns an empty array (or nil in case of error). Use only the predicates from the CNContact class predicates. This method doesn’t support compound predicates. Due to unification, the returned contacts may have different identifiers than you specify. To fetch all contacts, use enumerateContacts(with:usingBlock:). To include CNContactNoteKey in the array of keys in iOS, add the com.apple.developer.contacts.notes entitlement to your app. The entitlement requires permission from Apple to use, and you can’t publicly distribute your app until you have permission to use it. For more information about adding the entitlement and getting permission, see com.apple.developer.contacts.notes. note: In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Fetching contacts

- [enumerateContacts(with:usingBlock:)](contacts/cncontactstore/enumeratecontacts(with:usingblock:).md)
- [unifiedMeContactWithKeys(toFetch:)](contacts/cncontactstore/unifiedmecontactwithkeys(tofetch:).md)
- [unifiedContact(withIdentifier:keysToFetch:)](contacts/cncontactstore/unifiedcontact(withidentifier:keystofetch:).md)
