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

4

4 に答える 4

8

I found the issue.

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

Reza

于 2012-07-10T13:28:18.920 に答える
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
于 2013-03-07T07:21:47.030 に答える
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.

于 2014-03-06T16:24:59.650 に答える
0

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

于 2015-06-19T11:16:33.137 に答える