Re: NSData from NSArchiver and plist Utility
Re: NSData from NSArchiver and plist Utility
- Subject: Re: NSData from NSArchiver and plist Utility
- From: Trygve Inda <email@hidden>
- Date: Wed, 11 Jun 2008 20:12:33 +0000
- Thread-topic: NSData from NSArchiver and plist Utility
>
> On 11 Jun '08, at 9:35 AM, Trygve Inda wrote:
>
>> I have a plist that I will store on a server and my app will
>> retrieve it.
>> I'd like to archive one of the keys (an array) into an NSData and
>> possibly
>> compress it.... Makes for less storage and thus lower bandwidth for my
>> server.
>
> Why not just compress the entire plist? In my experience, zlib
> compresses markup data like XML by about 10::1.
>
>> myData = [NSArchiver archivedDataWithRootObject:(NSArray*)myArray];
>
> There's not much reason to use NSArchiver on plist-compatible data
> (arrays, strings, etc.) An XML archive will just be a much more
> verbose plist, and a binary archive will be identical to what you'd
> get if you used NSPropertyListSerialization to save a binary plist.
>
> (Binary plists are already quite a bit smaller than XML ones, and
> conveniently unreadable by eye, so you might just try that.)
Using NSData + zlib on an array of strings and number data in my
binary-stored plist saves about 25%...more than any other way.
While I could compress the entire plist, I would like to keep some of it
user-readable, and other parts obscured.
1714 - original size in bytes of binary plist
1562 - binary plist NSArray put through dataFromPropertyList and zlib
1331 - binary plist NSArray put through archivedDataWithRootObject and zlib
Trygve
_______________________________________________
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