我在探索EKEventKit。 我连接我的iPhone并拨打电话以安装日历
EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray * calendars = [eventDB calendars ];
但是,当我记录日历时,我收到此错误消息
“CADObjectGetIntProperty失败,错误错误 Domain = NSMachErrorDomain Code = 268435459“操作不能 完成。 (马赫错误268435459 - (ipc / send)无效的目的地 端口)“
有人知道这是什么以及为什么我会得到它。 感谢
礼
答案 0 :(得分:8)
我发现了这个问题。
我之前在我的代码中加载并保留了一个EKEventStore。删除其中一个解决了问题
Reza
答案 1 :(得分:2)
我的控制台上有相同的警告日志
早期代码:
"CalendarEventHandler.m"
eventStore = [[EKEventStore alloc] init];
"CalendarEventHandler.h"
@property (nonatomic,strong) EKEventStore *eventStore;
修改代码
self.eventStore = [[EKEventStore alloc] init];//This helped me to remove warning
答案 2 :(得分:2)
@discussion to EKEventStore
class 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."
此处写的内容如下:Reading and Writing Calendar Events,位于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]
。
这种方法也修复了警告。
答案 3 :(得分:0)
使实例'eventDB'成为类成员变量或属性可以解决问题。