将root.plist编辑为源代码会导致plist损坏 [英] Editing root.plist as source code results in corrupted plist
问题描述
我刚刚开始使用首选项文件,并且在我的设置包中编辑root.plist时立即开始遇到问题.每次在将属性编辑为属性列表时将其添加到plist时,XCode 4都会崩溃.因此,我认为我只是将其作为源代码进行编辑.这似乎容易得多.
I am just starting to work with preference files and I started having problems immediately when editing the root.plist in my settings bundle. My XCode 4 crashes every time I add a property to the plist while editing it as a property list. So I thought I would simply edit as source code. It seems to be a lot easier.
但是当我运行程序时,没有读取root.plist. (它与演示程序中的设置捆绑包一起正常工作.我使用的是InAppSettingsKit.)我在源代码编辑器中查看了root.plist,它看起来很正确.我试图将其视为属性列表,但收到一条错误消息,指出plist已损坏.
But when I run the program, the root.plist is not being read. (It was working fine with a settings bundle from a demo program. I'm using InAppSettingsKit.) I looked at the root.plist in the source code editor and it looks right. I tried to look at it as a property list and I get an error that says the plist is corrupted.
这是我的列表的内容.有人可以告诉我这是怎么回事吗?
Here is the contents of my plist. Can someone tell me what is wrong with it?
<?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>PreferenceSpecifiers</key>
<array>
<!-- Databases -->
<dict>
<key>Title</key> <string>Databases</string>
<key>Type</key> <string>PSGroupSpecifier</string>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>db0</string>
<key>Key</key> <string>db0_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>db1</string>
<key>Key</key> <string>db1_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<!-- Sharing Actions -->
<dict>
<key>Type</key> <string>PSGroupSpecifier</string>
<key>Title</key> <string>Sharing Actions</string>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>Facebook</string>
<key>Key</key> <string>facebook_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>Twitter</string>
<key>Key</key> <string>twitter_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>Email</string>
<key>Key</key> <string>email_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>BlogSpot</string>
<key>Key</key> <string>blogspot_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<!-- Automatic Email Enable -->
<dict>
<key>Type</key> <string>PSGroupSpecifier</string>
<key>Title</key> <string>Automatic Emailing</string>
</dict>
<dict>
<key>Type</key> <string>PSToggleSwitchSpecifier</string>
<key>Title</key> <string>Always Send to Email</string>
<key>Key</key> <string>autoblogspot_preference</string>
<key>DefaultValue</key> <true/>
</dict>
<!-- Calendar -->
<dict>
<key>Type</key> <string>PSRadioGroupSpecifier</string>
<key>Title</key> <string>First Day of the Week</string>
<key>Key</key> <string>firstDayOfTheWeek_preference</string>
<key>Values</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>3</integer>
<integer>4</integer>
<integer>5</integer>
<integer>6</integer>
</array>
<key>Titles</key>
<array>
<string>Sunday</string>
<string>Monday</string>
<string>Tuesday</string>
<string>Wednesday</string>
<string>Thursday</string>
<string>Friday</string>
<string>Saturday</string>
</array>
</dict>
<dict>
<key>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
推荐答案
在plist的最后,您有一个悬垂的键和dict标签.
At the very end of the plist you have a dangling key and dict tag.
第90行和第91行.
</dict>
<dict>
<key>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
应该是这样的:
</dict>
<dict />
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
或
</dict>
<dict>
<key>key</key><string>string</string>
</dict>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
我使用TextMate发现了这一点.捆绑包->属性列表->验证语法.不会告诉您确切的问题,但可以带您前往该地区.
I found this out using TextMate. Bundles -> Property List -> Validate Syntax. Doesn't tell you the exact problem, but gets you to the area.
通过尝试在属性列表编辑器"应用程序(/Developer/Applications/Utilities/Property List Editor.app)中打开plist,您还可以获得一行#来查看
You can also get a line # to look at by trying to open the plist in the Property List Editor app (/Developer/Applications/Utilities/Property List Editor.app)
列表是XML,因此任何XML验证器都会在语法中发现主要问题.经验法则是,对于每个标签,您都需要一个封闭标签.对于每个键,您都需要一个值.
空标签应该是<tag />
而不是<tag></tag>
.
Plists are XML, so any XML validator will find major problems in your syntax. Rule of thumb, though, is for every tag you need a close tag. For every key you need a value.
Empty tags should be <tag />
not <tag></tag>
.
这篇关于将root.plist编辑为源代码会导致plist损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!