帮助, 尝试从 EventKit 获取提醒列表的列表。 这只是不返回任何东西。如果我将 EKEntityType.Reminder 更改为 .Event,我会得到日历(事件),所以我知道代码通常是好的。
思想
var eventStore = EKEventStore()
func get_calendars(completed: (([EKCalendar])->())) {
print("in Get_Calendars")
let calendars = eventStore.calendarsForEntityType(EKEntityType.Reminder)
for calendar in calendars as [EKCalendar] {
// 2
print(calendar.title)
print(calendar.calendarIdentifier)
}
}
最佳答案
两个想法。
确保您已请求访问提醒:
let eventStore = EKEventStore() eventStore.requestAccessToEntityType(EKEntityType.Reminder, completion: { granted, error in if granted { let calendars = eventStore.calendarsForEntityType(.Reminder) for calendar in calendars as [EKCalendar] { print(calendar.title) print(calendar.calendarIdentifier) } } else { print("Permission denied by user") } })
确保您至少有一个提醒。如果您在模拟器中运行,您可能没有任何提醒,也不会看到日历。至少,这是我在测试时看到的。
关于ios - .calendarsForEntityType(EKEntityType.Reminder) 不返回提醒列表列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33193613/