Reputation: 1
for my project I am using the EventKit to access the calendar on an iPhone (iOS 5.1.1) and get all Events from the default calendar. That works fine. For each event I check hasAlarms, if true, I want to know the time of the alarm. So, something like this:
for (EKEvent *ev in allEventsArray){
if ([ev hasAlarms]){
NSArray *alarms = ev.alarms;
for (EKAlarm *alarm in alarms){
NSLog(@"%@",alarm.absoluteDate);
}
}
}
The problem is that I get "(null)" for the NSLog. I have no idea what I am doing wrong...
Can anybody help? Many thanks in advance!
Upvotes: 0
Views: 716
Reputation: 3238
EKAlarm will have an absoluteDate
OR a relativeOffset
. If absoluteDate is null then relativeOffset will have a value.
EKAlarm *alarmA = [EKAlarm alarmWithAbsoluteDate:[NSDate date]];
EKAlarm *alarmB = [EKAlarm alarmWithRelativeOffset: -300.0f];
NSLog(@"Absolute alarmA = %@", alarmA.absoluteDate);
NSLog(@"Absolute alarmB = %@", alarmB.absoluteDate);
NSLog(@"Relative alarmA = %f", alarmA.relativeOffset);
NSLog(@"Relative alarmB = %f", alarmB.relativeOffset);
NSLog resuts:
Absolute alarmA = 2012-07-27 00:19:06 +0000
Absolute alarmB = (null)
Relative alarmA = 0.000000
Relative alarmB = -300.000000
Upvotes: 2