我想知道如何以编程方式读取 iPhone 日历中的所有事件?
我知道我们可以检索已知日期的事件的方式。以下代码检索当前日期的事件。但是我怎样才能在 iPhone 日历中检索所有已保存的事件,即。不取决于日期?
NSDate *startDate = [NSDate date];
// endDate is 1 day = 60*60*24 seconds = 86400 seconds from startDate
NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:(86400*1)];
// Create the predicate. Pass it the default calendar.
NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArray];
// Fetch all events that match the predicate.
NSArray *events = [self.eventStore eventsMatchingPredicateredicate];