I'm trying to find the answer everywhere including StackOverflow.. I have a problem adding a time event from a string which looks like this: 2014-12-31T19:00:00-06:00. I'm parsing this from XML by the way. Rest of the code, including labels, etc. work fine.
So here is my code for adding a new events to the calendar (I tried to add 'dateFromString' already as a name with a current time to check and it goes through):
EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (!granted) { return; }
EKEvent *event = [EKEvent eventWithEventStore:store];
event.title = tempNameOfEvent;
event.startDate = dateFromString; //here is a NSDate but incorrectly formatted
event.endDate = [event.startDate dateByAddingTimeInterval:60*60]; //set 1 hour meeting
[event setCalendar:[store defaultCalendarForNewEvents]];
NSError *err = nil;
[store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
}];
Code from Programmatically add custom event in the iPhone Calendar
So, how should I format the NSDate to work with EKEventStore? Should I try to add it as "yyyy-MMM-dd HH:mm:ss ZZZ" which looks like "2007-01-09 17:00:00 +0000"? How to parse string and eliminate part with "-06:00"? (given time from XML looks like this: 2014-12-31T19:00:00-06:00).