Re: NSData to plist
Re: NSData to plist
- Subject: Re: NSData to plist
- From: Chris Kane <email@hidden>
- Date: Fri, 6 Dec 2002 08:48:48 -0800
On Friday, December 6, 2002, at 12:16 AM, Drew McCormack wrote:
On Friday, December 6, 2002, at 04:57 AM, crucial felix wrote:
I swiftly got it as an NSData, but now i'm trying to figure out how to
get it out of that.
i try using this: NSPropertyListSerialization method:
+ (id)propertyListFromData:(NSData *)data
mutabilityOption:(NSPropertyListMutabilityOptions)opt
format:(NSPropertyListFormat *)format errorDescription:(NSString
**)errorString
NSData *data = [NSData
dataWithContentsOfFile:[@"~/Music/iTunes/iTunes Music Library.xml"
stringByStandardizingPath]];
NSDictionary *plist = [NSPropertyListSerialization
propertyListFromData:data
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:NSPropertyListXMLFormat_v1_0
errorDescription:@"blah"];
The third parameter is a NSPropertyListFormat *, not
NSPropertyListFormat, as shown in the method declaration. Also the
fourth parameter is a NSString **, not an NSString *.
NSPropertyListFormat theFormat;
NSString *theError;
NSDictionary *plist = [NSPropertyListSerialization
propertyListFrom
Data:data
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&theFormat
errorDescription:&theError];
The format is returned to you, in case you want to preserve it because
you're going to modify and rewrite the file. The error string is also
returned by reference. Either of these parameters can be NULL instead
of a pointer to storage, if you don't want the value.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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.