0
votes

I have a dictionary that is written into a file after archiving it [NSKeyedArchiver archivedDataWithRootObject:dictionary] . I fetch the file contents and transferring the archived data to my peer devices through multipeer. Then, in my peer device, I am unarchiving the data using [NSKeyedUnarchiver unarchiveObjectWithData:data]. But, it is returning nil while unarchiving it, though data is present in it.

I am suspecting that the content is huge in file. Is there any alternative for NSkeyedArchiver/ NSKeyedUnarchiver ?

Code: Archiving:

[[NSKeyedArchiver archivedDataWithRootObject:dictionary] writeToFile:fileAtPath options:NSDataWritingAtomic error:&error];

Transferring:

[NSData dataWithContentsOfFile:fileAtPath] ;

Unarchiving:

[NSKeyedUnarchiver unarchiveObjectWithData:data];
1
how you are archiving and unarchiving? write your code - Ketan Parmar

1 Answers

0
votes

Try to write data like below,

 [data writeToFile:filePath atomically:NO];

here data means [NSKeyedArchiver archivedDataWithRootObject:dictionary] your archived data.

otherwise archived and unarchived method is fine.

Hope this will help :)