How can I delete all events in the default calendar when a button is tapped?
This is my current code
@IBAction func deleteEvents(_ sender: UIButton) {
eventStore.calendars(for: .event).removeAll()
}
The first problem it's not the current calendar. The second problem is that I get the following error:
Error:
Cannot use mutating member on immutable value: function call returns immutable value
There is no removeAll
method.
You need to use the methods of EKEventStore
to query and remove the desired events.
At a high level you need to:
EKCalendar
.All of the needed APIs are in the EKEventStore
class. See its documentation for specifics.