0

I got the data from the web service like the below order

<?xml version="1.0" encoding="UTF-8"?><Racine><Resultat_detaille><XML.03_-_Caisse_Snack><Espece>234,00</Espece><CA>234,00</CA><Offert>0,00</Offert></XML.03_-_Caisse_Snack>

But...

If the xml change to NSMutableDictionary, its goes to the sorting order.

"Resultat_detaille" =         {
    "XML.03_-_Caisse_Snack" =             {
        CA = "234,00";
        Espece = "234,00";
        Offert = "0,00";
    };

I don't want sorting, but the dictionary is sorted order. I am using the RestKit for getting the data from the web. How can I get the original data to the dictionary? Please help me. Thanks in advance.

4

2 回答 2

2

I don't know why you want to avoid this. But dictionary contains object in key-value pairs and it does not depend any sorting. But if you want the data in same manner as in XML, then you can parse it manually using NSXmlParse and also can store each dictionary object in array. like:

    arr[0] = CA -> "234,00";
    arr[1] = Espece -> "234,00";
    arr[2] = Offert -> "0,00";

I am not giving you actual code. I am telling only logic behind array objects here.

于 2013-02-06T15:45:14.550 回答
1

NSDictionary is not sorted, it is not an array, order has no meaning to a structure like a dictionary

From the looks of your xml, it has been correctly parsed into a dictionary

于 2013-02-06T15:34:41.577 回答