Objective C,使用 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>Categories</key>
<array>
<dict>
<key>CategoryName</key>
<string>Test Category</string>
<key>CategoryID</key>
<integer>10</integer>
<key>Sections</key>
<dict>
<key>A</key>
<array>
<string>A Jones</string>
<string>A King</string>
</array>
<key>T</key>
<array>
<string>T Jones</string>
<string>T King</string>
</array>
</dict>
</dict>
<dict>
<key>CategoryName</key>
<string>Another Test Category</string>
<key>CategoryID</key>
<integer>20</integer>
<key>Sections</key>
<dict>
<key>P</key>
<array>
<string>P Jones</string>
<string>P King</string>
</array>
<key>S</key>
<array>
<string>S Jones</string>
<string>S King</string>
</array>
</dict>
</dict>
</array>
</dict>
因此,我需要帮助的是如何根据所需的 CategoryID 获取每个部分中的人员。我认为对我来说主要问题是,如何确定要从中提取信息的 CategoryID(即我知道 CategoryID,但如何将其与正确的部分相关联),然后如何循环遍历每个部分键(a 、b、c 等),当键是节的名称时(这有意义吗?)。
非常感谢任何帮助和想法!谢谢!
another fun (and probably really simple) question for you, that I have half worked out and now run into a dead end...
I need to build an indexed table using data from a plist which looks something like this:
<?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>Categories</key>
<array>
<dict>
<key>CategoryName</key>
<string>Test Category</string>
<key>CategoryID</key>
<integer>10</integer>
<key>Sections</key>
<dict>
<key>A</key>
<array>
<string>A Jones</string>
<string>A King</string>
</array>
<key>T</key>
<array>
<string>T Jones</string>
<string>T King</string>
</array>
</dict>
</dict>
<dict>
<key>CategoryName</key>
<string>Another Test Category</string>
<key>CategoryID</key>
<integer>20</integer>
<key>Sections</key>
<dict>
<key>P</key>
<array>
<string>P Jones</string>
<string>P King</string>
</array>
<key>S</key>
<array>
<string>S Jones</string>
<string>S King</string>
</array>
</dict>
</dict>
</array>
</dict>
So, what I need help with is how to get the people in each section depending on the required CategoryID. I think the main problem for me is, how do I determine which CategoryID to pull info out of (ie I know the CategoryID, but how do I relate this to the correct section) and then how do i loop through each section key (a, b, c etc..) when the key is the name of the section (does that make sense?).
Any help and thoughts are greatly appreciated! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)