NSKeyedArchiver -> NSDictionary?
NSKeyedArchiver -> NSDictionary?
- Subject: NSKeyedArchiver -> NSDictionary?
- From: David Faden <email@hidden>
- Date: Wed, 24 Mar 2004 02:07:23 -0600
Hi,
Is there an elegant way to convert the data encoded by an
NSKeyedArchiver into a corresponding NSDictionary suitable for use with
NSUserDefaults? I was hoping to be able to use an NSKeyedArchiver in
building the default preferences for an app. The methods provided in
Foundation seem tantalizingly close to providing what I want. The
following code goes part of the way towards what seems to me an
inelegant solution (basically "manually" decomposing the property
list).
NSMutableData* data = [NSMutableData data];
NSKeyedArchiver* archiver = [[[NSKeyedArchiver alloc]
initForWritingWithMutable
Data:data] autorelease];
NSString* xmlString = nil;
id propertyListDictionary;
[archiver setOutputFormat:NSPropertyListXMLFormat_v1_0];
//archive some stuff ...
[archiver finishEncoding];
xmlString = [[[NSString alloc] initWith
Data:data
encoding:NSUTF8StringEncoding] autorelease];
propertyListDictionary = [xmlString propertyList];
//...
Is there a nice way to go from an NSKeyedArchiver to an NSDictionary in
a form suitable for use with NSUserDefaults?
Please CC replies to me as well as sending them to the list. (I have a
backlog of around 6400 cocoa-dev messages to sort through currently
:-)).
Thanks.
David
AIM: pitulx
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.