• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Understanding user defaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Understanding user defaults


  • Subject: Re: Understanding user defaults
  • From: James Montgomerie <email@hidden>
  • Date: Tue, 19 Mar 2013 10:40:47 +0000

On 19 Mar 2013, at 10:02, Marcel Weiher <email@hidden> wrote:

> On Mar 19, 2013, at 1:19 , Jens Alfke <email@hidden> wrote:
>
>>
>> On Mar 18, 2013, at 5:14 PM, Rick Mann <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >Understanding user defaults (From: Rick Mann <email@hidden>)
 >Re: Understanding user defaults (From: Graham Cox <email@hidden>)
 >Re: Understanding user defaults (From: Rick Mann <email@hidden>)
 >Re: Understanding user defaults (From: Jens Alfke <email@hidden>)
 >Re: Understanding user defaults (From: Rick Mann <email@hidden>)
 >Re: Understanding user defaults (From: Jens Alfke <email@hidden>)
 >Re: Understanding user defaults (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Re: Understanding user defaults
  • Next by Date: Week of month confusion?
  • Previous by thread: Re: Understanding user defaults
  • Next by thread: Re: Understanding user defaults
  • Index(es):
    • Date
    • Thread