在swift中获取有关EKEvent的信息

时间:2015-04-04 00:12:13

标签: xcode macos swift

我无法从日历中获取正确的数据。我可以访问日历并获取给定时间段内的所有事件。但是我无法获得EKEvent标题。 calendarItem中的标题是Allway吗?如果我有EKEevent,我该如何访问它?

let eventStore = EventStore.sharedInstance.eventStore
        for et in eventStore.calendarsForEntityType(EKEntityTypeEvent) {
            println(et)
        }

        let cals = eventStore.calendarsForEntityType(EKEntityTypeEvent)

        //today
        let today = NSDate()
        //yesterday
        let yesterday = NSDate()
        let last = yesterday.dateByAddingTimeInterval(-3259487.66)

        let fetchCalendarEvent =   
eventStore.predicateForEventsWithStartDate(last, endDate: today, calendars: 
cals)

        let eventlist = eventStore.eventsMatchingPredicate(fetchCalendarEvent)

        for test in eventlist{
            println(test)
        }

1 个答案:

答案 0 :(得分:0)

刚刚找到答案。 println(eventStore.calendarItemWithIdentifier(mob.calendarItemIdentifier).title)给了我想要的值