I want to load a NSDictionary from a plist and I have the plist string in memory, I don't have the plist file. NSDictionary dictionaryWithContentsOfFile: only accepts file name, it won't accept file string. How can I load the NSDictionary with a plist file?
Here you go...
NSData * data = [yourString dataUsingEncoding:NSUTF8StringEncoding];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSDictionary * dict = (NSDictionary*)[NSPropertyListSerialization
propertyListFromData:data
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format
errorDescription:&errorDesc];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With