2011-10-16 21 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