I am trying to create an app which has the ability to view calendar events. I am able to read all the properties but am having trouble with the EKAlarm. When I do an NSLog in the for loop it confirms that it should be hitting the 15min alarm log but it is passing over it.
for (int i = 0; i < [event1.alarms count]; i++) {
if ([event1.alarms objectAtIndex:i] == [EKAlarm alarmWithRelativeOffset:-900]) {
NSLog(@"alarm: 15 min before");
}else if([event1.alarms objectAtIndex:i] == [EKAlarm alarmWithRelativeOffset:-1800]) {
NSLog(@"alarm: 30 min before");
}else if([event1.alarms objectAtIndex:i] == [EKAlarm alarmWithRelativeOffset:-3600]) {
NSLog(@"alarm: 1 hour before");
}else if([event1.alarms objectAtIndex:i] == [EKAlarm alarmWithRelativeOffset:-86400]) {
NSLog(@"alarm: 1 day before");
}
}
What you’re doing here is comparing pointers between the EKAlarms that you saved in your NSArray and newly created alarms that you’re allocating at the time of the comparison.
What you could use to test for equality is the relativeOffset property in your alarms.
Something like: