我使用下面的代碼NSArray
EKEvent
轉換爲NSData
和轉換NSData
是unarchiveObjectWithData
到NSArray
。在轉換時,對象被更改並且它保存着值null
。NSKeyedUnarchiver unarchiveObjectWithData皈依問題
爲什麼會顯示NULL
。 (請參閱輸出)。任何人都知道解決方案讓我知道。提前致謝。
我編寫的代碼,
NSArray *events = [[self.eventStore eventsMatchingPredicate:predicate]retain];
NSData *arrayData = [NSKeyedArchiver archivedDataWithRootObject:events];
NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:arrayData];
輸出是
事件:( 「EKEvent < 0x4ad840> {EKEvent < 0x4ad840> {標題= 與日曆檢查;日曆= EKCalendar < 0x4bf2f0> {title = Calendar; type = Local; account =(null); allowsModify = YES; color = 0.443137 0.101961 0.462745 1.000000}; alarms =(\ n \「EKAlarm < 0x4be630> {triggerInterval = -300.000000} \「\ n); URL =(null); lastModified = 2012-05-14 12:15:32 +0000}; location =(null); startDate = 2012-05-11 01:30:00 +0000; endDate = 2012-05-19 17:30:00 +0000; allDay = 0; floating = 0; recurrence =(null);與會者=(空)} 「 )
陣列:( 」 EKEvent < 0x4c1e60> {EKEvent < 0x4c1e60> {標題=(空);日曆=(NULL);報警=(NULL); URL =( null); lastModified =(null)}; location =(null); startDate =(null); endDate =(null); allDay = 0; floating = 1; recurrence =(null); attendees =(null)}「 )
感謝Per Johansson,我會嘗試使用NSCoding並讓你知道。 – mdhanifas
我使用自定義類,並與NSCoding確認,但它不起作用。 它始終給出結果爲 ** EKEvent <0x46ba50> {EKEvent <0x46ba50> {title =(null);日曆=(空); alarm =(null); URL =(null); lastModified =(null)}; location =(null); startDate =(null); endDate =(null); allDay = 0; floating = 1; recurrence =(null);參加者=(null)} ** – mdhanifas