У меня есть следующий метод получения всех событий за текущий день:
- (NSArray *)fetchEventsForToday {
NSDate *startDate = [NSDate date];
// endDate is 1 day = 60*60*24 seconds = 86400 seconds from startDate
NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
// 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 eventsMatchingPredicate:predicate];
NSLog(@"array: %@", events);
return events;
}
Если я проверю свой NSLog, я получу следующий объект в массиве:
2011-06-29 19:24:01.383 SimpleEKDemo[2945:207] array: (
"EKEvent <0x5118cd0> { EKEvent <0x5118cd0> {
title = Test;
calendar = EKCalendar <0x5105d60> {
title = Calendar;
type = Local;
account = (null);
allowsModify = YES;
color = 0.443137 0.101961 0.462745 1.000000
};
alarms = (null);
URL = (null);
lastModified = 2011-06-29 23:51:51 +0000
};
location = (null);
startDate = 2011-06-30 00:30:00 +0000;
endDate = 2011-06-30 01:30:00 +0000;
allDay = 0;
floating = 0;
recurrence = (null);
attendees = (null)
}",
"EKEvent <0x5118380> {EKEvent <0x5118380> {
title = Prueba;
calendar = EKCalendar <0x5105d60> {
title = Calendar;
type = Local;
account = (null);
allowsModify = YES;
color = 0.443137 0.101961 0.462745 1.000000
};
alarms = (null);
URL = (null);
lastModified = 2011-06-29 23:51:58 +0000};
location = (null);
startDate = 2011-06-30 00:30:00 +0000;
endDate = 2011-06-30 01:30:00 +0000;
allDay = 0;
floating = 0;
recurrence = (null);
attendees = (null)
}",
"EKEvent <0x5117f70> {EKEvent <0x5117f70> {
title = Numero;
calendar = EKCalendar <0x5105d60> {
title = Calendar;
type = Local;
account = (null);
allowsModify = YES;
color = 0.443137 0.101961 0.462745 1.000000
};
alarms = (null);
URL = (null);
lastModified = 2011-06-29 23:53:54 +0000};
location = (null);
startDate = 2011-06-30 00:30:00 +0000;
endDate = 2011-06-30 01:30:00 +0000;
allDay = 0;
floating = 0;
recurrence = (null);
attendees = (null)
}"
Как видите, у меня есть 3 объекта: «test», «Prueba» и «Numero», этот заголовок, а также даты начала и окончания - это вся информация, которая мне нужна, но я не знаю, как ее получить.Кто-нибудь может мне помочь, пожалуйста?