我正在尝试使用 EventKit 从我在 iPhone 上订阅的日历中获取所有事件。
我只需要这个特定日历中的事件。
有可能得到它们吗?怎么办?
最佳答案
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)
}
关于ios - 从 iCal 获取事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31386973/