gpt4 book ai didi

arrays - 在 Swift 中读取 plist 文件的内容

转载 作者:行者123 更新时间:2023-11-30 11:54:12 25 4
gpt4 key购买 nike

前提:我是 Swift 的新手。

我试图将名为 fields.plist 的 plist 文件的内容加载到数组(称为“RootArray”)中。

这是 fields.plist 文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "..." "...">
<plist version="1.0">
<array>
<array>
<string>Question number one</string>
<dict>
<key>783612</key>
<string>Option number one 1</string>
<key>234739</key>
<string>Option number two 1</string>
<key>346837</key>
<string>Option number three 1</string>
</dict>
</array>
<array>
<string>Question number two</string>
<dict>
<key>928732</key>
<string>Option number one 2</string>
<key>263127</key>
<string>Option number two 2</string>
<key>332877</key>
<string>Option number three 2</string>
</dict>
</array>
</array>
</plist>

如何从中获取数组?谢谢!

最佳答案

Checking about "what's a way to store data locally in a command-line swift program". Found this comment: "Command line tools do use the Bundle structure: in other words, Bundle.main returns a valid bundle for the directory containing the command line executable. Bundle.main.resourceURL returns the url for the parent directory. Bundle.main.pathForResource("file", ofType:"xyz") would return a valid path provided file.xyz is copied into the same directory as the command line tool"

关于arrays - 在 Swift 中读取 plist 文件的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48010979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com