1

有没有办法从源代码在 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">
<array>
<dict>
    <key>title</key>
    <string>Title 1</string>
    //here i want to add one more string(value) how to do so?

    <key>subtitle</key>
    <string>Subtitle 1</string>
    <key>image</key>
    <string>image1.png</string>
</dict>

我在 plist 中想要的是...

Key Type Value value value

<?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>title</key>
    <string> 1</string>
    <string> 2 </string> 
     <string> 3</string>
    </dict>
 </Plist>
4

1 回答 1

5

不幸的是,字典使用键/值范式,这意味着给定键只有一个值。但是你可以设置一个包含两个字符串的数组,例如:

<key>title</key>
<array>
    <string>Title 1</string>
    <string>Title 2</string>
</array>
于 2012-12-05T10:37:48.620 回答