trung nguyen
trung nguyen

Reputation: 141

error when using EKEventEditViewController

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 :)

Upvotes: 3

Views: 2225

Answers (2)

Julian D.
Julian D.

Reputation: 5463

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
  }

Upvotes: 4

Airsource Ltd
Airsource Ltd

Reputation: 32622

I have pretty much the same problem. 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".

I noted in the debugger that normally when you cancel the event details are still present in EKEventEditController.event. However, if you cancel following the "No end date has been set" error, the event only contains a start and end time. The title has been wiped. My theory is that the reference to the eventStore has also been nilled out, which is what triggers the second error.

I interrupted the code following hitting OK on the "No end date error' but before hitting cancel and inspected the controller's event - but all looked ok, which means my theory can't be quite right. However there must be some disconnect appearing between the eventstore and the event for this error to appear.

I also get this problem only on iOS 5. My iOS 4.2 device is fine.

Upvotes: 0

Related Questions