3

I am exploring EKEventKit. I connect my iPhone and make the calls to get the calendars installed

EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray * calendars = [eventDB calendars ];

However when I log the calendars I get this error message

"CADObjectGetIntProperty failed with error Error Domain=NSMachErrorDomain Code=268435459 "The operation couldn’t be completed. (Mach error 268435459 - (ipc/send) invalid destination port)"

Does anybody know what this is and why I am getting it. Thanks

Reza

reza23
  • 3,079
  • 2
  • 27
  • 42
  • Apple has mentioned this as a known bug in this -https://developer.apple.com/library/ios/samplecode/SimpleEKDemo/Listings/ReadMe_txt.html – Vipin Johney Feb 17 '15 at 06:33

4 Answers4

8

I found the issue.

I had loaded and retained an EKEventStore previously in my code. Removing one of them solved the issue

Reza

reza23
  • 3,079
  • 2
  • 27
  • 42
  • I am having the same problem, and I think it has the same root cause, I tried [store release]; to no avail, how did you actually fix it? – Sparq Jul 10 '12 at 17:28
  • 2
    I am using auto reference counting in my project. On startup I create a EKEventStore that I assign to a variable, and so it is retained and then I use that EventStore for all my calendar calls. – reza23 Jul 10 '12 at 21:15
  • Yes, thats the approach I ended up taking. Thanks. – Sparq Jul 10 '12 at 23:30
  • Thank you, this was an iOS5 bug only, and now it fixed. thank you – Laszlo Dec 17 '13 at 15:25
2

I got same warning log on my console

Earlier code:

"CalendarEventHandler.m"
eventStore = [[EKEventStore alloc] init];


"CalendarEventHandler.h"

@property (nonatomic,strong) EKEventStore *eventStore;

Code Modified

self.eventStore = [[EKEventStore alloc] init];//This helped me to remove warning
Alphonse R. Dsouza
  • 2,011
  • 1
  • 14
  • 11
2

@discussion to EKEventStore class EKEventsStore.h file says:

"It is generally best to hold onto a long-lived instance of an event store, most likely as a singleton instance in your application."

The same is written here: Reading and Writing Calendar Events, in Connecting to the Event Store section:

"An EKEventStore object requires a relatively large amount of time to initialize and release. Consequently, you should not initialize and release a separate event store for each event-related task. Instead, initialize a single event store when your app loads, and use it repeatedly to ensure that your connection is long-lived."

So the right way to do this is:

@interface MyEventStore : EKEventStore

+ (MyEventStore *)sharedStore;

@end

+ (MyEventStore *)sharedStore
{
    static dispatch_once_t onceToken;
    static MyEventStore *shared = nil;
    dispatch_once(&onceToken, ^{
        shared = [[MyEventStore alloc] init];
    });
    return shared;
}

@end

and use it calling [MyEventStore sharedStore].

This approach also fixes the warning.

Anastasia
  • 3,024
  • 1
  • 23
  • 34
0

Make the instance 'eventDB' an class member variable or property can solve the problem.

frank
  • 2,327
  • 1
  • 18
  • 20