1

I know how to grab hold of the actual values of name, monsterLevel and monsterQueue deep dug into "World 1" > "Act 1" > "Dungeon 1" but I can't seem to figure out how to return the text "World 1" from in-between the <key> of my <dict>.

<?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>World 1</key>
        <dict>
            <key>Act 1</key>
            <dict>
                <key>Dungeon 1</key>
                <dict>
                    <key>name</key>
                    <string>d1name</string>
                    <key>monsterLevel</key>
                    <string>1</string>
                    <key>monsterQueue</key>
                    <string>0;0;0;0</string>
                </dict>
                <key>Dungeon 2</key>
                <dict>
                    <key>name</key>
                    <string>d2name</string>
                    <key>monsterLevel</key>
                    <string>2</string>
                    <key>monsterQueue</key>
                    <string>1;1;1;1</string>
                </dict>
            </dict>
        </dict>
    </dict>
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Lumpa
  • 57
  • 7
  • This appears to be a close relative of [this duplicate StackOverflow question](http://stackoverflow.com/questions/1072308/parse-plist-nsstring-into-nsdictionary). See if the answers here help you out. – Michael Dautermann Jan 20 '12 at 01:21

1 Answers1

3

It sounds like you want the string contained in the key? If so, you can get the keys of a dictionary using:

NSArray* keys = [myDictionary allKeys];

or, if you only want keys for a particular object, you can use:

NSArray* keys = [myDictionary allKeysForObject:someObject];
user1118321
  • 25,567
  • 4
  • 55
  • 86