I made an app which fetches all the calendar events through EventKit
but the code I wrote works only on particular title:
func readEvents() {
let eventStore = EKEventStore()
let calendars = eventStore.calendars(for: .event)
for calendar in calendars {
if calendar.title == "Work"{
//let predicate = eventStore.predicateForReminders(in: [calendar])
let oneMonthAgo = NSDate(timeIntervalSinceNow: -30*24*3600)
let oneMonthAfter = NSDate(timeIntervalSinceNow: +30*24*3600)
let predicate = eventStore.predicateForEvents(withStart: oneMonthAgo as Date, end: oneMonthAfter as Date, calendars: [calendar])
var events = eventStore.events(matching: predicate)
for event in events {
titles.append(event.title)
print([titles])
}
}
}
}
This only works for events which are in "work" calendar, how can I include all the events irrespective of the calendar?
Just remove this part?
if calendar.title == "Work"