0

I'm building an application that interacts with the macOS Reminder App. I'm trying to create a new Reminder list into which I later can import reminders.

This is what I have so far:

func setCalendar(_ type: EKEntityType) {

    let eventStore = EKEventStore()

    let newCalendar = EKCalendar(for: type, eventStore: eventStore)
    newCalendar.title="newcal"
    print("Cal: " + newCalendar.title)

    try? eventStore.saveCalendar(newCalendar, commit: true)

}

However, there is no reminder list being created.

Christian Seiler
  • 1,130
  • 1
  • 13
  • 29
  • How are you calling this function? Have you requested access to the reminders? Are capabilities set up correctly in your project? – Dávid Pásztor Aug 11 '17 at 16:29
  • Your code ignores errors silently, which is a very bad practice. What do you get if you replace the last line to `do {try eventStore.saveCalendar(newCalendar, commit: true);print("success")} catch {print(error)}` ? – OOPer Aug 11 '17 at 16:33
  • I call the function from a custom importer class using setCalendar(.reminder) from within init. I do request access to reminders and have all capabilities set correctly => I do get the existing reminder lists that I use for a drop down field. – Christian Seiler Aug 11 '17 at 16:36
  • I added the do {} catch {} => Calendar has no Source... how do I add a source to it? – Christian Seiler Aug 11 '17 at 16:41

1 Answers1

1

The problem is that you have omitted to specify the new calendar's .source. You cannot create a calendar of any kind (event or reminder) without doing that.

matt
  • 515,959
  • 87
  • 875
  • 1,141