2011-10-16 22 views
0

我刚刚开始使用首选项文件,并且在我的设置包中编辑root.plist时立即出现问题。每次向plist添加属性时,我的XCode 4都会崩溃,同时将其作为属性列表进行编辑。所以我想我会简单地编辑为源代码。这似乎更容易。编辑root.plist作为源代码导致plist损坏

但是当我运行程序时,root.plist没有被读取。 (它使用来自演示程序的设置包正常工作,我正在使用InAppSettingsKit。)我查看了源代码编辑器中的root.plist,它看起来是正确的。我试图把它看作一个属性列表,我得到一个错误,说plist已损坏。

这是我的plist的内容。有人能告诉我它有什么问题吗?

<?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> 

回答

2

在plist的最后,你有一个悬挂的键和字典标记。

行#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。包 - >属性列表 - >验证语法。没有告诉你确切的问题,但让你到这个地区。

您还可以得到一个行#试图打开的属性列表编辑器应用程序的plist中(/开发/应用/工具/属性列表Editor.app)

的Plist是XML,所以任何看XML验证器将在您的语法中找到主要问题。经验法则是,每个标签都需要一个密切的标签。对于每一个你需要价值的钥匙。 空标签应该是<tag />而不是<tag></tag>

+0

谢谢。我刚刚意识到我可以在线验证XML。它显示了同样的事情。所以这不是什么神秘的XCode事情。 – Jim