我正在探索EKEventKit。我连接我的iPhone并调用来安装日历
EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray * calendars = [eventDB calendars ];但是,当我记录日历时,我会得到以下错误消息:
"CADObjectGetIntProperty失败与错误Domain=NSMachErrorDomain Code=268435459“操作无法完成。(马赫错误268435459 -(ipc/发送)无效的目标端口)
有人知道这是什么以及我为什么要得到它吗。谢谢
雷扎
发布于 2012-07-10 13:28:18
我发现了问题。
我以前在代码中加载并保留了一个EKEventStore。他们中的一人解决了这个问题。
雷扎
发布于 2013-03-07 07:21:47
我的控制台上有同样的警告日志
早期代码:
"CalendarEventHandler.m"
eventStore = [[EKEventStore alloc] init];
"CalendarEventHandler.h"
@property (nonatomic,strong) EKEventStore *eventStore;码修改后的
self.eventStore = [[EKEventStore alloc] init];//This helped me to remove warning发布于 2014-03-06 16:24:59
@ EKEventStore类EKEventsStore.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."
所以正确的方法是:
@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]。
此方法还修正了警告。
https://stackoverflow.com/questions/11413371
复制相似问题