October 2013
Intermediate to advanced
1053 pages
28h 7m
English
You would like to be able to create new events in users’ calendars.
Find the calendar you want to insert your event into (please
refer to Recipe 19.1
and Recipe 19.2).
Create an object of type EKEvent
using the eventWithEventStore: class
method of EKEvent and save the event
into the user’s calendar using the saveEvent:span:error: instance method of
EKEventStore:
-(BOOL)createEventWithTitle:(NSString*)paramTitlestartDate:(NSDate*)paramStartDateendDate:(NSDate*)paramEndDateinCalendar:(EKCalendar*)paramCalendarinEventStore:(EKEventStore*)paramStorenotes:(NSString*)paramNotes{BOOLresult=NO;/* If a calendar does not allow modification of its contentsthen we cannot insert an event into it */if(paramCalendar.allowsContentModifications==NO){NSLog(@"The selected calendar does not allow modifications.");returnNO;}/* Create an event */EKEvent*event=[EKEventeventWithEventStore:paramStore];event.calendar=paramCalendar;/* Set the properties of the event such as its title,start date/time, end date/time, etc. */event.title=paramTitle;event.notes=paramNotes;event.startDate=paramStartDate;event.endDate=paramEndDate;/* Finally, save the event into the calendar */NSError*saveError=nil;result=[paramStoresaveEvent:eventspan:EKSpanThisEventerror:&saveError];if(result==NO){NSLog(@"An error occurred = %@",saveError);}returnresult;}
As you can see, this method expects a calendar object and ...
Read now
Unlock full access