On 19 Mar 2013, at 10:02, Marcel Weiher <marcel.wei...@gmail.com> wrote:

> On Mar 19, 2013, at 1:19 , Jens Alfke <j...@mooseyard.com> wrote:
> 
>> 
>> On Mar 18, 2013, at 5:14 PM, Rick Mann <rm...@latencyzero.com> wrote:
>> 
>>> NSArchiver calls look like -setValue:forKey:, so it seems reasonable that 
>>> the protocol could be usurped to write out fairly clean user defaults 
>>> plists.
>> 
>> There’s a lot of other gunk the archiver needs to store so it can handle 
>> pointer cycles and remember what classes to re-instantiate. As I said, look 
>> at some XML generated by NSArchiver sometime.
> 
> 
> Yes, but those can be handled in a cleaner way than what NSKeyedArchiver 
> does.  As an example, check out the "MPWXmlArchiver" in Objective-XML ( 
> https://github.com/mpw/Objective-XML ).  It reflects the object-graph as 
> directly in XML as possible, using the "id"/"idref" mechanism specified in 
> the XML spec to handle repeated occurrences of the same object.  I remember 
> people using it for debugging by dumping complex object graphs as XML.
> 
> It currently doesn't restrict the objects in the graph on reading, but that 
> would be a fairly simple exercise.

On a hopefully-not-overly-self-promotional tangent:  

If you're looking to debug - or just easily read - NSKeyedArchiver output, my 
'YACYAML' NSKeyedArchiver implementation produces YAML output that's really 
easy to read (and write).  It uses YAML 'anchors' to cope with deduplication 
similarly to MPWXmlArchiver. It's available at 
https://github.com/th-in-gs/YACYAML.

It does, of course, come with the same security caveats that any NSArchiver 
subclass should come with, as already discussed. There is a 
"YACYAMLKeyedUnarchiverOptionDisallowInitWithCoder" option that you can use 
though, which restricts it to decoding YAML-native classes (sets , 
dictionaries, strings, arrays etc.).

Jamie.



_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to