Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData to plist



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
propertyListFromData: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.

References: 
 >Re: NSData to plist (From: Drew McCormack <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.