---
title: commit()
framework: eventkit
role: symbol
role_heading: Instance Method
path: eventkit/ekeventstore/commit()
---

# commit()

Commits all unsaved changes to the event store.

## Declaration

```swift
func commit() throws
```

## Mentioned in

Creating events and reminders

## Discussion

Discussion This method allows you to save batched changes to the event store. For example, if you pass false as the commit parameter to the saveCalendar(_:commit:), removeCalendar(_:commit:), save(_:span:commit:), or remove(_:span:commit:) methods, the changes aren’t saved until commit() is invoked. Likewise, if you pass true as the commit parameter to the above methods, you don’t need to call commit(). 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. 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

### Saving and restoring state

- [reset()](eventkit/ekeventstore/reset().md)
- [refreshSourcesIfNecessary()](eventkit/ekeventstore/refreshsourcesifnecessary().md)
