首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EKCalendar与Domain=NSMachErrorDomain Code=268435459

EKCalendar与Domain=NSMachErrorDomain Code=268435459
EN

Stack Overflow用户
提问于 2012-07-10 12:31:03
回答 4查看 3.8K关注 0票数 3

我正在探索EKEventKit。我连接我的iPhone并调用来安装日历

代码语言:javascript
复制
EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray * calendars = [eventDB calendars ];

但是,当我记录日历时,我会得到以下错误消息:

"CADObjectGetIntProperty失败与错误Domain=NSMachErrorDomain Code=268435459“操作无法完成。(马赫错误268435459 -(ipc/发送)无效的目标端口)

有人知道这是什么以及我为什么要得到它吗。谢谢

雷扎

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-07-10 13:28:18

我发现了问题。

我以前在代码中加载并保留了一个EKEventStore。他们中的一人解决了这个问题。

雷扎

票数 8
EN

Stack Overflow用户

发布于 2013-03-07 07:21:47

我的控制台上有同样的警告日志

早期代码:

代码语言:javascript
复制
"CalendarEventHandler.m"
eventStore = [[EKEventStore alloc] init];


"CalendarEventHandler.h"

@property (nonatomic,strong) EKEventStore *eventStore;

码修改后的

代码语言:javascript
复制
self.eventStore = [[EKEventStore alloc] init];//This helped me to remove warning
票数 2
EN

Stack Overflow用户

发布于 2014-03-06 16:24:59

@ EKEventStoreEKEventsStore.h文件的讨论内容如下:

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

在这里也是这样写的:阅读和书写日历事件,在Connecting to the Event Store部分:

"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."

所以正确的方法是:

代码语言:javascript
复制
@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

并使用它调用[MyEventStore sharedStore]

此方法还修正了警告。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11413371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档