我一直想通过XML-RPC从服务器取回数据。为什么所有utf8字符串看起来都很奇怪?特别是,我不明白为什么其中一个(即“ title”)与“ post”相比看起来会有所不同?

<CFBasicHash 0x568c0e0 [0x14d7400]>{type = mutable dict, count = 4,
entries =>
 0 : <CFString 0x56378f0 [0x14d7400]>{contents = "title"} = <26233333 3bd0b1d0 b5d0b5d0 b5>
 1 : <CFString 0x568a300 [0x14d7400]>{contents = "id"} = <CFNumber 0x568c780 [0x14d7400]>{value = +15, type = kCFNumberSInt32Type}
 2 : <CFString 0x568cee0 [0x14d7400]>{contents = "time"} = <CFString 0x568cfa0 [0x14d7400]>{contents = "1295372714"}
 3 : <CFString 0x568d230 [0x14d7400]>{contents = "post"} = <CFString 0x568d310 [0x14d7400]>{contents = "\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0435\u043b\u0438\u043a\u0438\u0439 \u0430\u0440\u043c\u044f\u043d\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a"}

最佳答案

您不是从服务器取回字典吗?

尝试类似的方法:

NSData *data; // THIS IS YOUR RETURNED SERVER DATA

NSDictionary *dictionary;
NSError *error;

dictionary = (NSDictionary *) [NSPropertyListSerialization
                               propertyListFromData:data;
                                   mutabilityOption:NSPropertyListMutableContainersAndLeaves
                                             format:NULL
                                   errorDescription:&error];

if (!dictionary)
{
   NSLog(error);
   [error release];
}
else
{
   NSLog(dictionary);
}


认为完成字典后,您应该释放字典:

[dictionary release];


请参见NSPropertyListSerialization

07-28 12:10