I am making an iPhone app.
Table view has 3 views:(1) muscles -> (2) exercises (for that muscle) -> (3) exercise's detail
Here is the plist I currently have, its organized how it is because I followed a tutorial on how to make it work with tables and that is the format they used.
Here are a couple pictures of my .plist. I have two pics so you can see the name tag for the muscle is still in the same list (just after the child items).
http://www.box.net/shared/static/4i3yyjg0iq.png
http://www.box.net/shared/static/b1kkep55vd.png
Thanks!
Edit:
Here is the plist from text edit. (sorry for some reason I can't get the spacing right in for the post).
<array> <dict>
<key>ItemChild</key>
<array>
<dict>
<key>name</key>
<string>Ab Roller</string>
</dict>
<dict>
<key>name</key>
<string>Ab Crunch Machine</string>
</dict>
<dict>
<key>name</key>
<string>Advanced Kettlebell Windmill</string>
</dict>
</array>
<key>name</key>
<string>Abdominals</string>
</dict>
</array>
<key>name</key>
<string&开发者_Python百科gt;Abdominals</string>
</dict>
Your .plist is just a copy on disk of information that you need to have in memory when your program is running. If you can get the info, and your code works, then worrying about the formatting of the .plist file doesn't make much sense to me. Whatever works, works, in this case.
Update: Okay, I think that you can indeed make this both more concise and more meaningful. Here are my thoughts.
The base container of the info is an array. Each item in the array is a dictionary. The key/object pairs in the dictionary are the muscle's name, and an array of the exercises. Each item in the exercises array is another dictionary, whose key/object pairs are the name of the exercise, and whatever you decide to use for the detail. The end result will look like this:
<array>
<dict>
<key>muscleName</key>
<string>Abdominals</string>
<key>exercises</key>
<array>
<dict>
<key>exerciseName</key>
<string>Ab Roller</string>
<key>exerciseDetail</key>
<string></string> <!-- or possibly data -->
</dict>
<dict>
<key>exerciseName</key>
<string>Ab Crunch Machine</string>
<key>exerciseDetail</key>
<string></string>
</dict>
<dict>
<key>exerciseName</key>
<string>Advanced Kettlebell Windmill</string>
<key>exerciseDetail</key>
<string></string>
</dict>
<!-- more exercises? -->
</array>
<!-- End Abdominals -->
</dict>
<dict>
<key>muscleName</key>
<string>AnotherMuscle</string>
<key>exercises</key>
<array>
<!-- dicts of the exercises for this muscle -->
</array>
<!-- End AnotherMuscle -->
</dict>
<!-- more muscles -->
</array>
I think this will make your .plist creation easier, and make your coding easier and more readable, when you get to that stage.
If you have a huge amount of information (and it sounds like you do), you might also consider splitting it up into three (or more) files: Muscle Names, Exercises, Exercise Details.
精彩评论