You want to use NSPropertyListSerialization
:
NSData *data = [plistString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSArray *plist = [NSPropertyListSerialization
propertyListWithData:plistData
options:/*unused*/0
format:NULL
error:&error];
if (!plist) {
NSLog(@"%s: Failed to create plist: %@",
__func__, error ?: @"(unknown error)");
}
That particular method was introduced with iOS 4.0/Mac OS X 10.6. Prior to those releases, you would use:
NSData *data = [plistString dataUsingEncoding:NSUTF8StringEncoding];
NSString *errorText = nil;
NSArray *plist = [NSPropertyListSerialization
propertyListFromData:plistData
mutabilityOption:NSPropertyListImmutable
format:NULL
errorDescription:&errorText];
if (!plist) {
NSLog(@"%s: Failed to create plist: %@",
__func__, errorText ?: @"(unknown error)");
/* Part of the reason this method was replaced:
* It is the caller's responsibility to release the error description
* if any is returned. This is completely counter-intuitive.
*/
[errorText release], errorText = nil;
}