Contents

enumerateContacts(with:usingBlock:)

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

Declaration

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

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.

See Also

Fetching contacts