Processing a binary Plist
Can someone please let me know the difference between normal plist and binary plist and how they开发者_如何学运维 are different processing wise? Is there anything extra I need to do to process a binary plist?
Binary plists are not stored in human-readable XML like this:
<?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>SUFeedURL</key>
<string>http://www.hedgewars.org/download/appcast.xml</string>
<key>SUHasLaunchedBefore</key>
<true/>
<key>SULastCheckTime</key>
<date>2010-11-15T22:00:36Z</date>
</dict>
</plist>
Instead, they’re stored using Apple’s private methods, resulting in lower filesize. That example (preferences from Hedgewars) is 378 bytes, but in binary format is 162 bytes.
The good news is that built-in tools, such as NSUserDefaults
, will be able to use these formats interchangeably. Using other methods, such as NSArray
’s -arrayWithContentsOfFile:
method, ought to work as well.
To convert between the two, you can use the plutil
app, which is in /usr/bin
if installed on your Mac. Here’s an example:
plutil -convert xml1 /path/to/your/plist.plist
That will convert the plist at the given path to XML. Valid formats are (for now) xml1
and binary1
.
Be sure to check out the Property List Programming Guide, too.
精彩评论