Archiving/unarchiving root objects using instance methods
Archiving/unarchiving root objects using instance methods
- Subject: Archiving/unarchiving root objects using instance methods
- From: Paul Kim <email@hidden>
- Date: Mon, 9 Mar 2009 15:59:12 -0400
I have been using NSKeyedArchiver's +archivedDataWithRootObject:
method to create archives. Now, I want to create and read the same
archives but using a instances of NSKeyedArchiver and
NSKeyedUnarchiver instead of the class methods (so I can do things
like set a delegate, for instance). The problem is is that to produce
the same archive using instance methods as opposed to the class
convenience method, I have to encode the object with the undocumented
"root" key. I understand not wanting to expose that in the API but I
can't seem to find the methods to produce the same output using an
instance.
I've tried -encodeRootObject (defined in NSCoder) thinking
NSKeyedArchiver's version might do the right thing by encoding with an
implicit "root" key but not so. The resulting archive cannot be read
by NSKeyedUnarchiver's +unarchiveObjectWithData.
If I am missing something here, then let me know. And re-defining the
format is not acceptable as there are many files out there in the
field. It seems a bit silly if it is indeed the case that the
"convenience" methods provide no supported way to do it
"inconveniently." And yes, for practical reasons, using the "root" key
will work because of backwards compatibility but it would be nice if
there were an official way to do this (or some semi-official word that
using the "root" key is ok).
Thanks,
Paul Kim
_______________________________________________
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