Question

In my Application i need to attach(show iphone inbuilt calender) in-built iphone calendar on the UIButton action. More, The text from my UIViewControllers UILabel, I need attach that text in iphones in built calendar as reminder, where user is free to select date according his need. I had found like EventKIt framework may be useful to me, But i am not sure. And i am also not familiar with EventKit framework.

Was it helpful?

Solution

Just Use this example with EventKit framwork.

    -(IBAction)buttonAction:(id)sender
    {

        EKEventStore *eventStore = [[EKEventStore alloc] init];
        EKEventStore *eventStore = [[[EKEventStore alloc] init] autorelease];
        if([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])                {
            // iOS 6 and later
            [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
                if (granted){
                    //---- codes here when user allow your app to access theirs' calendar.
                    [self performCalendarActivity:eventStore];
                }else
                {
                    //----- codes here when user NOT allow your app to access the calendar.
                }
            }];
        }
         else {
                    //---- codes here for IOS < 6.0.
                    [self performCalendarActivity:eventStore];
        }           

    }

-(void)performCalendarActivity:(EKEventStore *)eventStore 

{
    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = @"EVENT TITLE";
event.startDate = [[NSDate alloc] init];
event.endDate   = [[NSDate alloc] initWithTimeInterval:600  sinceDate:event.startDate];
    [event setCalendar:[eventStore defaultCalendarForNewEvents]];
            NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
}

Don't forget to import #import <EventKit/EventKit.h> to your view controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top