0

我有以下eeee.txt文件:

<?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">
<array>
    <dict>
            <key>aa</key>
            <string>2012-06-29 17:12:45</string>
    </dict>
    <dict>
            <key>bb</key>
            <string>2012-06-29 17:12:59</string>
    </dict>
    <dict>
            <key>bb</key>
            <string>2012-06-29 17:13:03</string>
    </dict>
    <dict>
            <key>bb</key>
            <string>2012-06-29 17:13:06</string>
    </dict>
</array>
</plist>

在这里,我想删除重复的条目bb并将它们替换为最新的bb条目,即最后一个(因为它是最新timestamp的条目2012-06-29 17:13:06)。我想再次将其写入我的eeee.txt文件。我怎样才能做到这一点 ??谢谢并恭祝安康。

4

1 回答 1

0

Load this file into an NSDictionary using "dictionaryWithContentsOfFile:", then create a new NSMutableDictionary and load each entry into it while checking for duplicates. If you need this written back as a text file, use NSDictionary's "writeToFile:atomically:" method.

于 2012-07-03T06:46:22.870 回答