简体   繁体   English

以编程方式添加提醒列表

[英]Add Reminder List programmatically

I'm building an application that interacts with the macOS Reminder App. 我正在构建一个与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. 但是,没有创建提醒列表。

The problem is that you have omitted to specify the new calendar's .source . 问题是您已省略指定新日历的.source You cannot create a calendar of any kind (event or reminder) without doing that. 否则,您将无法创建任何类型的日历(事件或提醒)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM