【发布时间】:2017-08-11 16:27:45
【问题描述】:
我正在构建一个与 macOS 提醒应用程序交互的应用程序。我正在尝试创建一个新的提醒列表,稍后我可以将提醒导入其中。
这是我目前所拥有的:
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)
}
但是,没有创建提醒列表。
【问题讨论】:
-
你是怎么调用这个函数的?您是否请求访问提醒?您的项目中是否正确设置了功能?
-
您的代码会默默地忽略错误,这是一种非常糟糕的做法。如果将最后一行替换为
do {try eventStore.saveCalendar(newCalendar, commit: true);print("success")} catch {print(error)}会得到什么? -
我使用 init 中的 setCalendar(.reminder) 从自定义导入器类调用该函数。我确实请求访问提醒并正确设置了所有功能 => 我确实获得了用于下拉字段的现有提醒列表。
-
我添加了 do {} catch {} => 日历没有源...如何向它添加源?
标签: swift macos eventkit ekreminder