views:

61

answers:

1

On the Iphone im trying to populate a main table view from a dictionary, which works fine when the top level is an array ( see code below) , but for the life of me i cannot work out how to design the plist to reflect what I am trying to achieve - A top level array containing other arrays that contain dictionaries.

First table lists categories , for example

Beef dishes, Pork Dishes , Vegeterian

second tier lists items under the first tier - for instance Beef Dishes -> Crispy Beef , Beef Dishes -> BBQ Beef

the third tier is a full dictionary, detail name,fulltext description and image filename.

I have the system working on a 2 tier solution using :

<?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"&gt;
<plist version="1.0">
<array>
 <dict>
  <key>ettText</key>
  <string>Dont run with scissors</string>
  <key>ettDetail</key>
  <string>Its wery dangermouse</string>
 </dict>
 <dict>
  <key>ettText</key>
  <string>Dont pick your nose</string>
  <key>ettDetail</key>
  <string>Its Dirty</string>
 </dict>
 </array>
</plist>

I just cant get my head around adding a top level - should it be an array holding an array of dictionaries - any pointers?

A: 

You'd want to do a more complicated structure. For your dishes example, I'd do it like that:

<array>
  ...
  <dict>
    <key>name</key>
    <string>Beef dishes</string>
    ... // More properties for your categories
    <key>subcategories</key>
    <array>
      ...
      <dict>
        <key>name</key>
        <string>BBQ Beef</string>
        ... // More properties for your subcategories
        <key>items</key>
        <array>
          ...
          <dict>
            Fill in your contents here...
          </dict>
          ...
        </array>
      </dict>
      ...
    </array>
  </dict>
  ...
</array>

I'm feeling hungry now... ;)

Max Seelemann
Great, now i see it in print, it all makes sense. Thank you.
richedav