2012-07-10 158 views
3

我在探索EKEventKit。 连接我的iPhone和打的电话,以获得日历安装EKCalendar和错误域= NSMachErrorDomain代码= 268435459

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

但是当我登录的日历我收到此错误信息

“CADObjectGetIntProperty失败,错误错误 域= NSMachErrorDomain代码= 268435459“操作无法完成, 。 (马赫错误268435459 - (IPC /发送)无效的目标 端口)”

有谁知道这是什么,为什么我得到它 感谢

+0

苹果已经提到这是一个已知的错误在这个-https://developer.apple.com/library/ios/samplecode/SimpleEKDemo/Listings/ReadMe_txt.html – 2015-02-17 06:33:07

回答

8

我发现这个问题。

我就装在我的代码先前保持的EKEventStore。卸下其中一个解决问题

+0

我有同样的问题,我认为它已经同样的根本原因,我尝试[商店发布];无济于事,你是如何真正解决它的? – Sparq 2012-07-10 17:28:07

+2

我在我的项目中使用自动引用计数。在启动时,我创建了一个EKEventStore,将其分配给一个变量,并保留它,然后使用该EventStore来处理所有日历调用。 – reza23 2012-07-10 21:15:32

+0

是的,那是我最终采取的方法。谢谢。 – Sparq 2012-07-10 23:30:21

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

@discussion到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."

同样是在这里写:Reading and Writing Calendar Events,在Connecting to the Event Store部分:

因此,要做到这一点,正确的方法是:

@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]

该方法还修复了警告。

0

使实例'eventDB'成为一个类成员变量或属性可以解决问题。

相关问题