你有一个字符串来描述你的数组(或者可能是几个数组?)作为一系列字节存储在NSMutableData对象中。为了将其重新转换为数组,您将需要分析var_dump输出,该输出可能很艰难。
如果你能找到一个库(或滚你自己的代码)在苹果的plist格式返回你的数据,你的任务会更容易:你可以使用
[NSPropertyListSerialization propertyListFromData:mutabilityOption:format:errorDescription:]
这需要一个NSData(或NSMutableData )指针作为它的第一个参数。尝试http://code.google.com/p/cfpropertylist/作为起点。
从在cfpropertylist页面示例代码:
$plist = new CFPropertyList();
$td = new CFTypeDetector();
$guessedStructure = $td->toCFType($array);
$plist->add($guessedStructure);
// and then return the plist content with
$plist->toXML()
,并在您的iOS代码:
NSString *errorString = nil;
NSArray *array = [[NSPropertyListSerialization
propertyListFromData:theData
mutabilityOption:NSPropertyListImmutable
format:nil
errorDescription:&errorString] retain];
重用这个美丽的工作对我来说 的NSMutableDictionary *字典= [[NSPropertyListSerialization propertyListFromData:myNSMutableData mutabilityOption: NSPropertyListImmutable格式:nil errorDescription:&errorString] retain]; – jcpennypincher 2011-09-09 21:53:18