NSArray *arrayDate = [strDate componentsSeparatedByString:@"/"];
NSString *strFinalDate = [NSString stringWithFormat:@"%@-%@-%@ 9:00:00",@"2012",[arrayDate objectAtIndex:0],[arrayDate objectAtIndex:1]];
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSDate *startDate = [format dateFromString:strFinalDate];
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = [NSString stringWithFormat:@"%@'s Birthday",strName];
NSDate *twoYearsFromNow = [NSDate dateWithTimeIntervalSinceNow:1577846275];
double alarmAmountInSeconds = 60*60*9;
EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:(1.0*alarmAmountInSeconds)];
EKRecurrenceRule *recurrance;
recurrance = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyYearly interval:1 end:[EKRecurrenceEnd recurrenceEndWithEndDate:twoYearsFromNow]];
NSMutableArray *arrayReccurence = [NSMutableArray arrayWithObject:recurrance];
event.recurrenceRules = arrayReccurence;
event.startDate = startDate;
event.endDate = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];
event.allDay = true;
event.alarms = [NSArray arrayWithObject:alarm];
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
NSString *strFinalDate = [NSString stringWithFormat:@"%@-%@-%@ 9:00:00",@"2012",[arrayDate objectAtIndex:0],[arrayDate objectAtIndex:1]];
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSDate *startDate = [format dateFromString:strFinalDate];
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = [NSString stringWithFormat:@"%@'s Birthday",strName];
NSDate *twoYearsFromNow = [NSDate dateWithTimeIntervalSinceNow:1577846275];
double alarmAmountInSeconds = 60*60*9;
EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:(1.0*alarmAmountInSeconds)];
EKRecurrenceRule *recurrance;
recurrance = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyYearly interval:1 end:[EKRecurrenceEnd recurrenceEndWithEndDate:twoYearsFromNow]];
NSMutableArray *arrayReccurence = [NSMutableArray arrayWithObject:recurrance];
event.recurrenceRules = arrayReccurence;
event.startDate = startDate;
event.endDate = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];
event.allDay = true;
event.alarms = [NSArray arrayWithObject:alarm];
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
No comments:
Post a Comment