dd-plist does not decode the plist file exactly.

108 views
Skip to first unread message

Nguyen Toan

unread,
Dec 5, 2012, 6:14:38 AM12/5/12
to plist-...@googlegroups.com
Hi author of dd-plist library,

I got the plist(toan.plist) that was created in iOS app just like the following

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>35</integer>
</dict>
<key>NS.keys</key>
<array>
<dict>
<key>CF$UID</key>
<integer>2</integer>
</dict>
</array>
<key>NS.objects</key>
<array>
<dict>
<key>CF$UID</key>
<integer>3</integer>
</dict>
</array>
</dict>
<string>documentStructure</string>
...
</dict>
</plist>

And then I used dd-plist library to decode and get the string but this one is not same to that one I saw on my iMac and here it is

<plist version="1.0">
<dict>
<key>$top</key>
<dict>
<key>root</key>
<string>01</string>
</dict>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>NS.objects</key>
<array>
<string>03</string>
</array>
<key>NS.keys</key>
<array>
<string>02</string>
</array>
<key>$class</key>
<string>23</string>
</dict>
<string>documentStructure</string>

My code that I wrote like the following 

File file = new File("toan.plist");
NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(file);
Log.d("Toan", "data:" + rootDict.toXMLPropertyList());

Please review it and let me know how get the exact string(the body of toan.plist) in android through dd-plist library.

Yours, Toan

Daniel Dreibrodt

unread,
Dec 5, 2012, 7:41:26 AM12/5/12
to plist-...@googlegroups.com
Hello Toan,

the order of the elements in a dictionary can differ between what is the input and the output. But the tree structure should be the same.

Regards,
Daniel

Thanh Bui

unread,
Dec 5, 2012, 1:24:06 PM12/5/12
to plist-...@googlegroups.com
Hi Daniel,

This issue happened when we parse a binary plist generated from iOS. We need to get the position of NS.Object from UID array:

<key>NS.objects</key>

<array>

    <dict>

        <key>CF$UID</key>

        <integer>4</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>8</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>11</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>17</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>21</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>24</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>27</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>30</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>32</integer>

    </dict>

    <dict>

        <key>CF$UID</key>

        <integer>35</integer>

    </dict>

</array>


but when we iterate through this array and convert each member of this array to UID, we can not get the integer value. (We tried to convert the UID to XMLPropertyList but the value returned not correct: they were: (04,08,0b,11,15,18,1b,1e,20,23) (while we expected they were: (4, 8, 11, 17, 21, 24, 27, 30, 32, 35)).

Please let me know if you have any idea.

Thanks

Thanh Bui

unread,
Dec 5, 2012, 1:29:30 PM12/5/12
to plist-...@googlegroups.com
Hi,

I tried to convert the value 04,08,0b,11,15,18,1b,1e,20,23 from hex to decimal and it work. 

Thanks


On Thursday, December 6, 2012 1:24:06 AM UTC+7, Thanh Bui wrote:
Hi Daniel,

This issue happened when we parse a binary plist generated from iOS. We need to get the position of NS.Object from UID array:

Thanh Bui

unread,
Dec 5, 2012, 1:32:08 PM12/5/12
to plist-...@googlegroups.com
However, I still have a question: is there any way to get the integer value from UID directly?

Daniel Dreibrodt

unread,
Dec 6, 2012, 5:14:05 AM12/6/12
to plist-...@googlegroups.com
It looks like you are working with a property list that was created using the NSKeyedArchiver. Such property lists have a special format and are not yet fully supported in my library as I did not yet have the time to examine their format in detail.

To convert the UID byte array to an int, see: http://stackoverflow.com/questions/1026761/how-to-convert-a-byte-array-to-its-numeric-value-java

Thanh Bui

unread,
Dec 8, 2012, 5:57:02 AM12/8/12
to plist-...@googlegroups.com
Thanks for your information, however the UID class in your library is a kind of dictionary:

    <dict>

        <key>CF$UID</key>

        <integer>4</integer>

    </dict>

so when I call UID.getByte() it return the byte array of the whole string above. At the moment my workaround solution is get the string of UID by calling UID.toXMLPropertyList() then substring to get the hexa value of the id and convert it to int. It's quite long process. Hope that you can find a better way in the future ;). 

Reply all
Reply to author
Forward
0 new messages