Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error when using EKEventEditViewController

Tags:

ios5

I have the following code :

EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];

EKEvent * event = [EKEvent eventWithEventStore:eventStore];

event.startDate = startDate;

event.endDate = endDate;

addController.eventStore = self.eventStore;

addController.event = event;

addController.editViewDelegate = self;

[self presentModalViewController:addController animated:YES];   
[addController release];

It show me a screen to add event like iCal, but when I press "done" button to add event I got an alert "That event does not belong to that event store." and in console log I got "Calendar: unable to save: Error Domain=EKErrorDomain Code=11 "That event does not belong to that event store." UserInfo=0xfecb150 {NSLocalizedDescription=That event does not belong to that event store.}" , but this just occur in iOS 5., ok with 4. Can anyone help me this :)

like image 502
trung nguyen Avatar asked Jan 21 '26 11:01

trung nguyen


1 Answers

I get the same behaviour as described by @Airsource Ltd in his answer:

... If I try and save an event which has starttime == endtime, then I initally get an error "No end date has been set". If I then set a different end time, I get "That event does not belong to that event store".

However, this only seems to happen if the event's initial values for startDate and endDate are exactly equal.

This seems to be an iOS 5 bug. My workaround: make the event's initial startDate and endDate always differ just a bit, e.g. a second:

  if ([event.endDate isEqualToDate:event.startDate]) {
    event.endDate = [event.startDate dateByAddingTimeInterval:1.0]; // add one second
  }
like image 105
Julian D. Avatar answered Jan 23 '26 21:01

Julian D.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!