iphone xml-rpc utf8字符串

时间:2011-01-20 16:31:24

标签: iphone cocoa utf-8 xml-rpc

我很难通过XML-RPC从我的服务器获取数据。为什么所有的utf8字符串看起来都很奇怪?特别是,我不明白为什么他们中的一个(这是'标题')与'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"}

1 个答案:

答案 0 :(得分:0)

你没有从服务器上取回字典吗?

尝试类似:

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