Search code examples
iphoneeventkitekeventkit

how to enter all the data in calendar without using EventkitUI ? (iphone)


I recently saw eventkit framework.

And I used it successfully.

now the situation is ...

I have all the data which is suppose to be entered in eventkit ... now I dont want to use the uieventkit framework .

I have my tableview in which all the details which are necessary to fill data in calendar is there .

So I want to add all this data without using eventkitUI . I dont want to show up that UI of eventkit

can anyone tell me how to do this ??


Solution

  • Here is a code snippet to help you starting out. You will need to fill-in the details using your event data. The code shows how to add a non recurring event. For recurring events you will need to add additional details about the event recurrence. Note that the snippet does not release allocated objects but you need to do proper memory management as usual.

    EKEventStore *eventStore = [[EKEventStore alloc] init];
    EKCalendar *calendar = [eventStore defaultCalendarForNewEvents];
    EKEvent *event = [EKEvent eventWithEventStore:eventStore];
    event.calendar = çalendar;
    event.title = yourTitle; 
    event.notes = yourNotes; 
    event.startDate = yourStartDate; 
    event.endDate = yourEndDate;
    
    NSError *saveError = nil;
    result = [eventStore saveEvent:event span:EKSpanThisEvent error:&saveError];