I am using the following code to convert NSArray EKEvent to NSData and the converted NSData is unarchiveObjectWithData to NSArray. While converting, the object is changed and it holds the null value.
Why does it show NULL. (Refer to the output). Anyone know the solution let me know. Thanks in Advance.
The code I written,
NSArray *events = [[self.eventStore eventsMatchingPredicate:predicate]retain];
NSData *arrayData = [NSKeyedArchiver archivedDataWithRootObject:events];
NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:arrayData];
The Output is
events : ( "EKEvent <0x4ad840> {EKEvent <0x4ad840> {title = Checking with Calendar; calendar = 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); attendees = (null)}" )
Array : ( "EKEvent <0x4c1e60> {EKEvent <0x4c1e60> {title = (null); calendar = (null); alarms = (null); URL = (null); lastModified = (null)}; location = (null); startDate = (null); endDate = (null); allDay = 0; floating = 1; recurrence = (null); attendees = (null)}" )
While
NSArrayconfirms to theNSCodingprotocol,EKEventdoes not. It's a bit surprising that you don't get an exception running the code, the class must confirm toNSCodingfor archiving to work.