Saad Umar
Saad Umar

Reputation: 604

EKEvent creating events for ios 5 application?

every one i am using EKEventStore to add events into iphone calender from my app, its working for the devices of ios version 4.2, and from my application the events are added into ical perfectly but when i installed the same app in ipod with ios version 5, strangely the events are not adding into ical, here is my function to add the events,

-(void)icall_add{


 //daily_trackAppDelegate *controller2 =(daily_trackAppDelegate *) [[UIApplication sharedApplication] delegate];
    EKEventStore *eventStore = [[EKEventStore alloc] init];

    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = text2.text;
    //event.attendees = controller2.who;
    event.notes= text3.text;


    //controller2.new_event_title = @"";
    //controller2.new_recent_location = @"";


    event.startDate = mydatepicker.date;
    //event.endDate   = [[NSDate alloc] initWithTimeInterval:3600 sinceDate:event.startDate];
    event.endDate = mydatepicker.date;

    [event setCalendar:[eventStore defaultCalendarForNewEvents]];
    NSError *err;
    [eventStore saveEvent:event span:EKSpanThisEvent error:&err];  
    daily_trackAppDelegate *controller2 =(daily_trackAppDelegate *) [[UIApplication sharedApplication] delegate];

    text1.text = @"";
    text2.text = @"";
    text3.text = @"";
    controller2.who = @"";
    controller2.new_event_title = @"";
    controller2.new_recent_location = @"";
}

please guide what is that problem n how to solve it, thanx in advance, Regards Saad.

Upvotes: 0

Views: 2309

Answers (3)

Brijesh Vadukia
Brijesh Vadukia

Reputation: 922

Here is answer

EKEvent start time and End time should not be same. It will not allow to add event in iOS 4 and older version but it wil allow to add event in iOS 5.

Add at least one second to make different between start date and end date.

   NSDate *endDate = [startDate dateByAddingTimeInterval:1];

Upvotes: 1

Nikesh K
Nikesh K

Reputation: 621

I just check your code, you are adding the start and end date for a new event and saving it. I doubt the start and end date, it cannot be the same, atleast the difference in time is must for a event to occur. Just assign the start and end date with some different time intervals.

Upvotes: 2

Nikesh K
Nikesh K

Reputation: 621

I hope you know that in iOS 5, they have made some changes in methods for adding a event, making recurrence rule etc, check apple docs to get rid of that. I am also working on it, once i figured it out i can post it here.

Upvotes: 0

Related Questions