2013-08-02 12 views
1

我需要在我的應用程序中開發日曆應用程序,以便我需要從本機日曆中取得事件,然後才能確定我們如何知道本機中有多少年日曆?我們如何檢索數據?日曆的執行

+0

?您是否看到Apple樣片:SimpleEKDemo或生日? – Larme

回答

2

您可以使用EKEventStore類從用戶的日曆數據庫中獲取所有事件。 你得到的所有事件形成eventstore只是把你嘗試過什麼的開始日期爲[NSDate distantPast]和結束日期爲[NSDate distantFuture]

self.eventStore = [[EKEventStore alloc] init]; 
NSPredicate *fetchCalendarEvents = [self.eventStore predicateForEventsWithStartDate:[NSDate distantPast] endDate:[NSDate distantFuture] calendars:calendarArray]; 

NSArray *allEvents = [self.eventStore eventsMatchingPredicate:fetchCalendarEvents];