I had a simple question. How can I get all the events in iCal that overlap the current time. It's actually dead simple! Just ask the calendar store for the predicate with a start date and end date the same.
NSPredicate *eventsPredicate = [CalCalendarStore eventPredicateWithStartDate:[NSDate date] endDate:[NSDate date] calendars:[[CalCalendarStore defaultCalendarStore] calendars]];
NSArray *calendarEvents = [[CalCalendarStore defaultCalendarStore] eventsWithPredicate:eventsPredicate];
NSArray *calendarEvents = [[CalCalendarStore defaultCalendarStore] eventsWithPredicate:eventsPredicate];
When executed calendarEvents will have all events that have a start date less than or equal to the current date and an end date greater than or equal to the current date.
No comments:
Post a Comment