2012-07-10 39 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'成爲一個類成員變量或屬性可以解決問題。

相關問題