• 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
NSKeyedArchiver -> NSDictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] initForWritingWithMutableData:data] autorelease];
NSString* xmlString = nil;
id propertyListDictionary;

[archiver setOutputFormat:NSPropertyListXMLFormat_v1_0];
//archive some stuff ...
[archiver finishEncoding];
xmlString = [[[NSString alloc] initWithData: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.


  • Follow-Ups:
    • Re: NSKeyedArchiver -> NSDictionary?
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: How to define a method IMP for use as a C callback?
  • Next by Date: Re: how to make my plugin appears like a package ?
  • Previous by thread: NSMutableURLRequest setHTTPMethod:
  • Next by thread: Re: NSKeyedArchiver -> NSDictionary?
  • Index(es):
    • Date
    • Thread