---
title: "enumerateEvents(matching:using:)"
framework: EventKit
role: symbol
role_heading: Instance Method
platforms: [iOS 4.0+, iPadOS 4.0+, Mac Catalyst 13.1+, macOS 10.8+, visionOS 1.0+, watchOS 2.0+]
path: eventkit/ekeventstore/1507518-enumerateevents
---

# enumerateEvents(matching:using:)

Finds all events that match a given predicate and calls a given callback for each event found.

## Declaration

```swift
func enumerateEvents(matching predicate: NSPredicate, using block: @escaping EKEventSearchCallback)
```

## Parameters

- `predicate`: A search predicate created with [doc://com.apple.eventkit/documentation/EventKit/EKEventStore/predicateForEvents(withStart:end:calendars:)](eventkit/ekeventstore/predicateforevents(withstart:end:calendars:).md).
- `block`: The closure to call for each event. The callback must match the signature defined by [doc://com.apple.eventkit/documentation/EventKit/EKEventSearchCallback](eventkit/ekeventsearchcallback.md).

## Discussion

Only committed events are included in the enumeration. To include events saved using [save(_:span:commit:)](save(_:span:commit:).md) with the `commit` parameter set to [false](../../swift/false.md), call [commit()](commit().md) first.

This method is synchronous. For asynchronous behavior, run the method on another thread with [dispatch_async](../../dispatch/dispatch_async.md) or [Operation](../../foundation/operation.md).

## See Also

### Searching calendars

- [events(matching:)](events(matching:).md)
- [fetchReminders(matching:completion:)](fetchreminders(matching:completion:).md)
- [cancelFetchRequest(_:)](cancelfetchrequest(_:).md)
- [predicateForEvents(withStart:end:calendars:)](predicateforevents(withstart:end:calendars:).md)
- [predicateForReminders(in:)](predicateforreminders(in:).md)
- [predicateForCompletedReminders(withCompletionDateStarting:ending:calendars:)](predicateforcompletedreminders(withcompletiondatestarting:ending:calendars:).md)
- [predicateForIncompleteReminders(withDueDateStarting:ending:calendars:)](predicateforincompletereminders(withduedatestarting:ending:calendars:).md)
- [EKEventSearchCallback](../ekeventsearchcallback.md)
