プログラムで 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];