I will add an event to the calendar.
My code is correct but I need the date and the time from Datepicker.
How to set date and time from the datepicker for the following code:
EKEventStore *es = [[EKEventStore alloc] init];
[es requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
/* This code will run when uses has made his/her choice */
EKEvent *myEvent = [EKEvent eventWithEventStore:es];
myEvent.title = @"New Event";
myEvent.startDate = [NSDate date]; // I need to set date from Datepicker
NSTimeInterval interval = 60*+5; // I need to set time from Datepicker
EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:interval];
[myEvent addAlarm:alarm];
myEvent.endDate = [[NSDate date] initWithTimeInterval:600 sinceDate:myEvent.startDate];
[myEvent setCalendar:[es defaultCalendarForNewEvents]];
NSError *err;
[es saveEvent:myEvent span:EKSpanThisEvent error:&err];
}];
You can see the comment where I will set the date and time.
Thanks.