---
title: "enumerateContacts(with:usingBlock:)"
framework: contacts
role: symbol
role_heading: Instance Method
path: "contacts/cncontactstore/enumeratecontacts(with:usingblock:)"
---

# enumerateContacts(with:usingBlock:)

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

## Declaration

```swift
func enumerateContacts(with fetchRequest: CNContactFetchRequest, usingBlock block: (CNContact, UnsafeMutablePointer<ObjCBool>) -> Void) throws
```

## Parameters

- `fetchRequest`: The contact fetch request that specifies the search criteria.
- `block`: Called for each contact matching the fetch request.

## Return Value

Return Value true if enumeration of all contacts matching a contact fetch request executes successfully; otherwise, false. Discussion This method waits until the enumeration is finished. If there are no results, the block is not called and the method returns true. This method can fetch all contacts without keeping all of them at once in memory, which is expensive. note: In Swift, this method returns Void 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

- [unifiedMeContactWithKeys(toFetch:)](contacts/cncontactstore/unifiedmecontactwithkeys(tofetch:).md)
- [unifiedContact(withIdentifier:keysToFetch:)](contacts/cncontactstore/unifiedcontact(withidentifier:keystofetch:).md)
- [unifiedContacts(matching:keysToFetch:)](contacts/cncontactstore/unifiedcontacts(matching:keystofetch:).md)
