On 14/10/2009, at 10:24 AM, Graham Cox wrote:

It can also be parsed by the Property List Editor utility, which at least gives you a glimpse at the names of the classes and keys used. It takes some detective work but you can even work out what keys are with which class. It's not much, but it's something.


One quick way to get a rough look at an archive is to load it into a dictionary using -dictionaryWithContentsOfURL: In that dictionary are four keyed items. One of them is a large array keyed by '$objects'. If you just log that array it gives you most of what you need to know.

Where an object references another it does so using a private object class CFKeyedArchiverUID, which appears to simply hold the index of the $objects array item it refers to. This object does write out a sensible description to the log despite being private, so the index it points to is easily read as its "value". (Note that these references are removed from the display when examining an archive with the Property List Editor utility, but they are crucial for decoding an archive). Each dearchivable object is represented by a dictionary whose key/value pairs are simply the keys and values that were written by the -encodeWithCoder: method. There is also the key $class which points, via a CFKeyedArchiverUID, to another dictionary which contains $classes -> an array giving the class inheritance structure of the object as a simple list of strings and $classname -> the classname again (same as element 0 in the $classes array).

So while the format isn't public, it's pretty easy to reverse engineer as there's no real trickery going on, just a fairly extensive effort to avoid writing the same info more than once.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to