How to find all keys used in NSKeyedArchiver/NSKeyedUnarchiver
Asked Answered
I

1

6

I have an NSData that was created by using NSKeyedArchiver. Is there a way to iterate over all the values inside it? It must somehow be possible to get all the keys that were stored in it when using +[NSKeyedUnarchiver unarchiveObjectWithData:].

Thanks

Impercipient answered 8/5, 2012 at 12:43 Comment(1)
AFAIK there is no way to do that. Depending on the use case, you might want to encode and decode a dictionary object.Sporades
R
1

A NSKeyedArchived file "simply" is a property list. You would need to find out the structure of that plist, though.

I found the source code of Cocotron very helpful one day, as I tried to decode some NSKeyedUnarchived data: http://code.google.com/p/cocotron/source/browse/Foundation/NSKeyedArchiving/NSKeyedUnarchiver.m (Maybe look at line 39 (initForReadingWithData:) which is called by unarchiveObjectWithData: (line #164)).

Maybe you can find out more about the archived objects that way.

Ravenna answered 8/5, 2012 at 13:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.