我有以下方法,用于获取当天的所有事件:
- (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”这个标题以及开始和结束日期是我需要的所有信息,但我不知道如何获得它。有人可以帮帮我吗?