Accessing NSKeyedArchiver's archivedDataWithRootObject by name
Accessing NSKeyedArchiver's archivedDataWithRootObject by name
- Subject: Accessing NSKeyedArchiver's archivedDataWithRootObject by name
- From: "Jim Turner" <email@hidden>
- Date: Tue, 9 Dec 2008 12:17:56 -0600
I have a situation where I'm archiving an array of objects via
NSKeyedArchiver's archivedDataWithRootObject: and later needing to set
a delegate on the NSKeyedUnarchiver that decodes it. The
documentation is a bit unclear on how one starts the unarchive process
when a NSKeyedUnarchiver is created on an archive where you don't
know, for certain, the keys it contains.
So my question... is this legitimate?
NSKeyedUnarchiver *_keyedUnarchiver = [[[NSKeyedUnarchiver alloc]
initForReadingWithData:archivedData] autorelease];
[_keyedUnarchiver setDelegate:self];
NSMutableArray *archivedArray = [_keyedUnarchiver decodeObjectForKey:@"root"];
[_keyedUnarchiver finishDecoding];
It works, but I always question things when I hard-code a string for
something. Will 'root' always be the key that represents the root
object?
If I could do something like [NSKeyedUnarchiver
unarchiveObjectWithData:delegate:], that would be better than perfect.
--
Jim
http://nukethemfromorbit.com
_______________________________________________
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