gpt4 book ai didi

ios - SWIFT 和 EventKit

转载 作者:行者123 更新时间:2023-11-28 13:15:31 26 4
gpt4 key购买 nike

大家好,我是 swift 和 Events Kit 的新手,我得到了这行代码,我可以从中打印事件而不是日历名称吗?

    var eventStore = EKEventStore()
eventStore.requestAccessToEntityType(EKEntityTypeEvent,
completion: {(granted: Bool, error:NSError!) in
if !granted {
println("Access to store not granted")
}
})

let events = eventStore.calendarsForEntityType(EKEntityTypeEvent)

for events in events as [EKCalendar] {
println("events = \(events.title)")

}

最佳答案

我知道有两种方法可以从 EKEventStore 获取事件,但是它们都需要谓词,通常使用开始/结束日期和日历数组来检查。

let predicate = store.predicateForEventsWithStartDate(startDate, endDate: endDate, calendars: nil) // nil calendar checks all calendars, otherwise pass [EKCalendar]

使用:

let events = store.eventsMatchingPredicate(predicate) as [EKEvent]

或者:

store.enumerateEventsMatchingPredicate(predicate) { event, stop in

}

关于ios - SWIFT 和 EventKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29186703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com