2011-01-20 111 views
1

我一直無法通過XML-RPC從我的服務器獲取數據。爲什麼所有的utf8字符串看起來很奇怪?特別是,我不明白爲什麼他們中的一個(這是'title')與'post'相比看起來不同?iphone xml-rpc utf8字符串

<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"} 

回答

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

+0

乾杯隊友。我回來了NSDictionary,我不知道我應該用編碼做什麼。 – danilabagroff 2011-01-20 17:19:04