【问题标题】:Get events from iCal从 iCal 获取事件
【发布时间】:2015-07-13 15:06:48
【问题描述】:
我正在尝试从我在 iPhone 上使用 EventKit 订阅的日历中获取所有事件。
我只需要这个特定日历中的事件。
有可能得到它们吗?怎么样?
【问题讨论】:
标签:
ios
swift
icalendar
eventkit
【解决方案1】:
private func getAllEvents() {
let store = EKEventStore()
let cal = store.calendarWithIdentifier(yourCalenderIdentifier)
let oneMonthAgo = NSDate(timeIntervalSinceNow: -30*24*3600)
let oneMonthAfter = NSDate(timeIntervalSinceNow: +30*24*3600)
let predicate = store.predicateForEventsWithStartDate(oneMonthAgo, endDate: oneMonthAfter, calendars: [cal!])
let events = store.eventsMatchingPredicate(predicate)
}